Don't share query editor state after project find has been split
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
1e04411066
commit
7123407f42
2 changed files with 70 additions and 26 deletions
|
@ -43,6 +43,7 @@ pub struct MultiBuffer {
|
|||
title: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct History {
|
||||
next_transaction_id: TransactionId,
|
||||
undo_stack: Vec<Transaction>,
|
||||
|
@ -168,6 +169,37 @@ impl MultiBuffer {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn clone(&self, new_cx: &mut ModelContext<Self>) -> Self {
|
||||
let mut buffers = HashMap::default();
|
||||
for (buffer_id, buffer_state) in self.buffers.borrow().iter() {
|
||||
buffers.insert(
|
||||
*buffer_id,
|
||||
BufferState {
|
||||
buffer: buffer_state.buffer.clone(),
|
||||
last_version: buffer_state.last_version.clone(),
|
||||
last_parse_count: buffer_state.last_parse_count,
|
||||
last_selections_update_count: buffer_state.last_selections_update_count,
|
||||
last_diagnostics_update_count: buffer_state.last_diagnostics_update_count,
|
||||
last_file_update_count: buffer_state.last_file_update_count,
|
||||
excerpts: buffer_state.excerpts.clone(),
|
||||
_subscriptions: [
|
||||
new_cx.observe(&buffer_state.buffer, |_, _, cx| cx.notify()),
|
||||
new_cx.subscribe(&buffer_state.buffer, Self::on_buffer_event),
|
||||
],
|
||||
},
|
||||
);
|
||||
}
|
||||
Self {
|
||||
snapshot: RefCell::new(self.snapshot.borrow().clone()),
|
||||
buffers: RefCell::new(buffers),
|
||||
subscriptions: Default::default(),
|
||||
singleton: self.singleton,
|
||||
replica_id: self.replica_id,
|
||||
history: self.history.clone(),
|
||||
title: self.title.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_title(mut self, title: String) -> Self {
|
||||
self.title = Some(title);
|
||||
self
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue