Fixup cases using buffer model handle id as buffer id

This commit is contained in:
Julia 2023-05-03 14:12:29 -04:00
parent 1883e260ce
commit eacea55aaf
8 changed files with 71 additions and 55 deletions

View file

@ -3222,14 +3222,18 @@ async fn test_canceling_buffer_opening(
.unwrap(); .unwrap();
// Open a buffer as client B but cancel after a random amount of time. // Open a buffer as client B but cancel after a random amount of time.
let buffer_b = project_b.update(cx_b, |p, cx| p.open_buffer_by_id(buffer_a.id() as u64, cx)); let buffer_b = project_b.update(cx_b, |p, cx| {
p.open_buffer_by_id(buffer_a.read_with(cx_a, |a, _| a.remote_id()), cx)
});
deterministic.simulate_random_delay().await; deterministic.simulate_random_delay().await;
drop(buffer_b); drop(buffer_b);
// Try opening the same buffer again as client B, and ensure we can // Try opening the same buffer again as client B, and ensure we can
// still do it despite the cancellation above. // still do it despite the cancellation above.
let buffer_b = project_b let buffer_b = project_b
.update(cx_b, |p, cx| p.open_buffer_by_id(buffer_a.id() as u64, cx)) .update(cx_b, |p, cx| {
p.open_buffer_by_id(buffer_a.read_with(cx_a, |a, _| a.remote_id()), cx)
})
.await .await
.unwrap(); .unwrap();
buffer_b.read_with(cx_b, |buf, _| assert_eq!(buf.text(), "abc")); buffer_b.read_with(cx_b, |buf, _| assert_eq!(buf.text(), "abc"));

View file

@ -126,7 +126,7 @@ impl CopilotServer {
struct RunningCopilotServer { struct RunningCopilotServer {
lsp: Arc<LanguageServer>, lsp: Arc<LanguageServer>,
sign_in_status: SignInStatus, sign_in_status: SignInStatus,
registered_buffers: HashMap<usize, RegisteredBuffer>, registered_buffers: HashMap<u64, RegisteredBuffer>,
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
@ -162,7 +162,7 @@ impl Status {
} }
struct RegisteredBuffer { struct RegisteredBuffer {
id: usize, id: u64,
uri: lsp::Url, uri: lsp::Url,
language_id: String, language_id: String,
snapshot: BufferSnapshot, snapshot: BufferSnapshot,
@ -267,7 +267,7 @@ pub struct Copilot {
http: Arc<dyn HttpClient>, http: Arc<dyn HttpClient>,
node_runtime: Arc<NodeRuntime>, node_runtime: Arc<NodeRuntime>,
server: CopilotServer, server: CopilotServer,
buffers: HashMap<usize, WeakModelHandle<Buffer>>, buffers: HashMap<u64, WeakModelHandle<Buffer>>,
} }
impl Entity for Copilot { impl Entity for Copilot {
@ -582,7 +582,7 @@ impl Copilot {
} }
pub fn register_buffer(&mut self, buffer: &ModelHandle<Buffer>, cx: &mut ModelContext<Self>) { pub fn register_buffer(&mut self, buffer: &ModelHandle<Buffer>, cx: &mut ModelContext<Self>) {
let buffer_id = buffer.id(); let buffer_id = buffer.read(cx).remote_id();
self.buffers.insert(buffer_id, buffer.downgrade()); self.buffers.insert(buffer_id, buffer.downgrade());
if let CopilotServer::Running(RunningCopilotServer { if let CopilotServer::Running(RunningCopilotServer {
@ -596,7 +596,8 @@ impl Copilot {
return; return;
} }
registered_buffers.entry(buffer.id()).or_insert_with(|| { let buffer_id = buffer.read(cx).remote_id();
registered_buffers.entry(buffer_id).or_insert_with(|| {
let uri: lsp::Url = uri_for_buffer(buffer, cx); let uri: lsp::Url = uri_for_buffer(buffer, cx);
let language_id = id_for_language(buffer.read(cx).language()); let language_id = id_for_language(buffer.read(cx).language());
let snapshot = buffer.read(cx).snapshot(); let snapshot = buffer.read(cx).snapshot();
@ -641,7 +642,8 @@ impl Copilot {
cx: &mut ModelContext<Self>, cx: &mut ModelContext<Self>,
) -> Result<()> { ) -> Result<()> {
if let Ok(server) = self.server.as_running() { if let Ok(server) = self.server.as_running() {
if let Some(registered_buffer) = server.registered_buffers.get_mut(&buffer.id()) { let buffer_id = buffer.read(cx).remote_id();
if let Some(registered_buffer) = server.registered_buffers.get_mut(&buffer_id) {
match event { match event {
language::Event::Edited => { language::Event::Edited => {
let _ = registered_buffer.report_changes(&buffer, cx); let _ = registered_buffer.report_changes(&buffer, cx);
@ -695,7 +697,7 @@ impl Copilot {
Ok(()) Ok(())
} }
fn unregister_buffer(&mut self, buffer_id: usize) { fn unregister_buffer(&mut self, buffer_id: u64) {
if let Ok(server) = self.server.as_running() { if let Ok(server) = self.server.as_running() {
if let Some(buffer) = server.registered_buffers.remove(&buffer_id) { if let Some(buffer) = server.registered_buffers.remove(&buffer_id) {
server server
@ -800,7 +802,8 @@ impl Copilot {
Err(error) => return Task::ready(Err(error)), Err(error) => return Task::ready(Err(error)),
}; };
let lsp = server.lsp.clone(); let lsp = server.lsp.clone();
let registered_buffer = server.registered_buffers.get_mut(&buffer.id()).unwrap(); let buffer_id = buffer.read(cx).remote_id();
let registered_buffer = server.registered_buffers.get_mut(&buffer_id).unwrap();
let snapshot = registered_buffer.report_changes(buffer, cx); let snapshot = registered_buffer.report_changes(buffer, cx);
let buffer = buffer.read(cx); let buffer = buffer.read(cx);
let uri = registered_buffer.uri.clone(); let uri = registered_buffer.uri.clone();
@ -919,7 +922,9 @@ fn uri_for_buffer(buffer: &ModelHandle<Buffer>, cx: &AppContext) -> lsp::Url {
if let Some(file) = buffer.read(cx).file().and_then(|file| file.as_local()) { if let Some(file) = buffer.read(cx).file().and_then(|file| file.as_local()) {
lsp::Url::from_file_path(file.abs_path(cx)).unwrap() lsp::Url::from_file_path(file.abs_path(cx)).unwrap()
} else { } else {
format!("buffer://{}", buffer.id()).parse().unwrap() format!("buffer://{}", buffer.read(cx).remote_id())
.parse()
.unwrap()
} }
} }

View file

@ -2594,7 +2594,7 @@ impl Editor {
let old_text = buffer.text_for_range(old_range.clone()).collect::<String>(); let old_text = buffer.text_for_range(old_range.clone()).collect::<String>();
let newest_selection = self.selections.newest_anchor(); let newest_selection = self.selections.newest_anchor();
if newest_selection.start.buffer_id != Some(buffer_handle.id()) { if newest_selection.start.buffer_id != Some(buffer_handle.read(cx).remote_id()) {
return None; return None;
} }
@ -2802,7 +2802,7 @@ impl Editor {
), ),
); );
} }
multibuffer.push_transaction(entries.iter().map(|(b, t)| (b, t))); multibuffer.push_transaction(entries.iter().map(|(b, t)| (b, t)), cx);
multibuffer multibuffer
}); });
@ -5764,7 +5764,7 @@ impl Editor {
cx: &mut ViewContext<Workspace>, cx: &mut ViewContext<Workspace>,
) { ) {
// If there are multiple definitions, open them in a multibuffer // If there are multiple definitions, open them in a multibuffer
locations.sort_by_key(|location| location.buffer.id()); locations.sort_by_key(|location| location.buffer.read(cx).remote_id());
let mut locations = locations.into_iter().peekable(); let mut locations = locations.into_iter().peekable();
let mut ranges_to_highlight = Vec::new(); let mut ranges_to_highlight = Vec::new();
@ -6059,7 +6059,7 @@ impl Editor {
buffer.update(&mut cx, |buffer, cx| { buffer.update(&mut cx, |buffer, cx| {
if let Some(transaction) = transaction { if let Some(transaction) = transaction {
if !buffer.is_singleton() { if !buffer.is_singleton() {
buffer.push_transaction(&transaction.0); buffer.push_transaction(&transaction.0, cx);
} }
} }

View file

@ -704,10 +704,10 @@ impl Item for Editor {
this.update(&mut cx, |editor, cx| { this.update(&mut cx, |editor, cx| {
editor.request_autoscroll(Autoscroll::fit(), cx) editor.request_autoscroll(Autoscroll::fit(), cx)
})?; })?;
buffer.update(&mut cx, |buffer, _| { buffer.update(&mut cx, |buffer, cx| {
if let Some(transaction) = transaction { if let Some(transaction) = transaction {
if !buffer.is_singleton() { if !buffer.is_singleton() {
buffer.push_transaction(&transaction.0); buffer.push_transaction(&transaction.0, cx);
} }
} }
}); });

View file

@ -43,7 +43,7 @@ pub struct ExcerptId(usize);
pub struct MultiBuffer { pub struct MultiBuffer {
snapshot: RefCell<MultiBufferSnapshot>, snapshot: RefCell<MultiBufferSnapshot>,
buffers: RefCell<HashMap<usize, BufferState>>, buffers: RefCell<HashMap<u64, BufferState>>,
next_excerpt_id: usize, next_excerpt_id: usize,
subscriptions: Topic, subscriptions: Topic,
singleton: bool, singleton: bool,
@ -85,7 +85,7 @@ struct History {
#[derive(Clone)] #[derive(Clone)]
struct Transaction { struct Transaction {
id: TransactionId, id: TransactionId,
buffer_transactions: HashMap<usize, text::TransactionId>, buffer_transactions: HashMap<u64, text::TransactionId>,
first_edit_at: Instant, first_edit_at: Instant,
last_edit_at: Instant, last_edit_at: Instant,
suppress_grouping: bool, suppress_grouping: bool,
@ -145,7 +145,7 @@ pub struct ExcerptBoundary {
struct Excerpt { struct Excerpt {
id: ExcerptId, id: ExcerptId,
locator: Locator, locator: Locator,
buffer_id: usize, buffer_id: u64,
buffer: BufferSnapshot, buffer: BufferSnapshot,
range: ExcerptRange<text::Anchor>, range: ExcerptRange<text::Anchor>,
max_buffer_row: u32, max_buffer_row: u32,
@ -337,7 +337,7 @@ impl MultiBuffer {
offset: T, offset: T,
theme: Option<&SyntaxTheme>, theme: Option<&SyntaxTheme>,
cx: &AppContext, cx: &AppContext,
) -> Option<(usize, Vec<OutlineItem<Anchor>>)> { ) -> Option<(u64, Vec<OutlineItem<Anchor>>)> {
self.read(cx).symbols_containing(offset, theme) self.read(cx).symbols_containing(offset, theme)
} }
@ -394,7 +394,7 @@ impl MultiBuffer {
is_insertion: bool, is_insertion: bool,
original_indent_column: u32, original_indent_column: u32,
} }
let mut buffer_edits: HashMap<usize, Vec<BufferEdit>> = Default::default(); let mut buffer_edits: HashMap<u64, Vec<BufferEdit>> = Default::default();
let mut cursor = snapshot.excerpts.cursor::<usize>(); let mut cursor = snapshot.excerpts.cursor::<usize>();
for (ix, (range, new_text)) in edits.enumerate() { for (ix, (range, new_text)) in edits.enumerate() {
let new_text: Arc<str> = new_text.into(); let new_text: Arc<str> = new_text.into();
@ -593,7 +593,7 @@ impl MultiBuffer {
if let Some(transaction_id) = if let Some(transaction_id) =
buffer.update(cx, |buffer, cx| buffer.end_transaction_at(now, cx)) buffer.update(cx, |buffer, cx| buffer.end_transaction_at(now, cx))
{ {
buffer_transactions.insert(buffer.id(), transaction_id); buffer_transactions.insert(buffer.read(cx).remote_id(), transaction_id);
} }
} }
@ -614,12 +614,12 @@ impl MultiBuffer {
} }
} }
pub fn push_transaction<'a, T>(&mut self, buffer_transactions: T) pub fn push_transaction<'a, T>(&mut self, buffer_transactions: T, cx: &mut ModelContext<Self>)
where where
T: IntoIterator<Item = (&'a ModelHandle<Buffer>, &'a language::Transaction)>, T: IntoIterator<Item = (&'a ModelHandle<Buffer>, &'a language::Transaction)>,
{ {
self.history self.history
.push_transaction(buffer_transactions, Instant::now()); .push_transaction(buffer_transactions, Instant::now(), cx);
self.history.finalize_last_transaction(); self.history.finalize_last_transaction();
} }
@ -644,7 +644,7 @@ impl MultiBuffer {
cursor_shape: CursorShape, cursor_shape: CursorShape,
cx: &mut ModelContext<Self>, cx: &mut ModelContext<Self>,
) { ) {
let mut selections_by_buffer: HashMap<usize, Vec<Selection<text::Anchor>>> = let mut selections_by_buffer: HashMap<u64, Vec<Selection<text::Anchor>>> =
Default::default(); Default::default();
let snapshot = self.read(cx); let snapshot = self.read(cx);
let mut cursor = snapshot.excerpts.cursor::<Option<&Locator>>(); let mut cursor = snapshot.excerpts.cursor::<Option<&Locator>>();
@ -785,8 +785,8 @@ impl MultiBuffer {
let (mut tx, rx) = mpsc::channel(256); let (mut tx, rx) = mpsc::channel(256);
let task = cx.spawn(|this, mut cx| async move { let task = cx.spawn(|this, mut cx| async move {
for (buffer, ranges) in excerpts { for (buffer, ranges) in excerpts {
let buffer_id = buffer.id(); let (buffer_id, buffer_snapshot) =
let buffer_snapshot = buffer.read_with(&cx, |buffer, _| buffer.snapshot()); buffer.read_with(&cx, |buffer, _| (buffer.remote_id(), buffer.snapshot()));
let mut excerpt_ranges = Vec::new(); let mut excerpt_ranges = Vec::new();
let mut range_counts = Vec::new(); let mut range_counts = Vec::new();
@ -855,7 +855,7 @@ impl MultiBuffer {
where where
O: text::ToPoint + text::ToOffset, O: text::ToPoint + text::ToOffset,
{ {
let buffer_id = buffer.id(); let buffer_id = buffer.read(cx).remote_id();
let buffer_snapshot = buffer.read(cx).snapshot(); let buffer_snapshot = buffer.read(cx).snapshot();
let (excerpt_ranges, range_counts) = let (excerpt_ranges, range_counts) =
build_excerpt_ranges(&buffer_snapshot, &ranges, context_line_count); build_excerpt_ranges(&buffer_snapshot, &ranges, context_line_count);
@ -924,7 +924,7 @@ impl MultiBuffer {
self.sync(cx); self.sync(cx);
let buffer_id = buffer.id(); let buffer_id = buffer.read(cx).remote_id();
let buffer_snapshot = buffer.read(cx).snapshot(); let buffer_snapshot = buffer.read(cx).snapshot();
let mut buffers = self.buffers.borrow_mut(); let mut buffers = self.buffers.borrow_mut();
@ -1051,7 +1051,7 @@ impl MultiBuffer {
let buffers = self.buffers.borrow(); let buffers = self.buffers.borrow();
let mut cursor = snapshot.excerpts.cursor::<Option<&Locator>>(); let mut cursor = snapshot.excerpts.cursor::<Option<&Locator>>();
for locator in buffers for locator in buffers
.get(&buffer.id()) .get(&buffer.read(cx).remote_id())
.map(|state| &state.excerpts) .map(|state| &state.excerpts)
.into_iter() .into_iter()
.flatten() .flatten()
@ -1321,7 +1321,7 @@ impl MultiBuffer {
.collect() .collect()
} }
pub fn buffer(&self, buffer_id: usize) -> Option<ModelHandle<Buffer>> { pub fn buffer(&self, buffer_id: u64) -> Option<ModelHandle<Buffer>> {
self.buffers self.buffers
.borrow() .borrow()
.get(&buffer_id) .get(&buffer_id)
@ -1478,8 +1478,8 @@ impl MultiBuffer {
for (locator, buffer, buffer_edited) in excerpts_to_edit { for (locator, buffer, buffer_edited) in excerpts_to_edit {
new_excerpts.push_tree(cursor.slice(&Some(locator), Bias::Left, &()), &()); new_excerpts.push_tree(cursor.slice(&Some(locator), Bias::Left, &()), &());
let old_excerpt = cursor.item().unwrap(); let old_excerpt = cursor.item().unwrap();
let buffer_id = buffer.id();
let buffer = buffer.read(cx); let buffer = buffer.read(cx);
let buffer_id = buffer.remote_id();
let mut new_excerpt; let mut new_excerpt;
if buffer_edited { if buffer_edited {
@ -1605,11 +1605,11 @@ impl MultiBuffer {
let buffer_handle = if rng.gen() || self.buffers.borrow().is_empty() { let buffer_handle = if rng.gen() || self.buffers.borrow().is_empty() {
let text = RandomCharIter::new(&mut *rng).take(10).collect::<String>(); let text = RandomCharIter::new(&mut *rng).take(10).collect::<String>();
buffers.push(cx.add_model(|cx| Buffer::new(0, text, cx))); buffers.push(cx.add_model(|cx| Buffer::new(0, text, cx)));
let buffer = buffers.last().unwrap(); let buffer = buffers.last().unwrap().read(cx);
log::info!( log::info!(
"Creating new buffer {} with text: {:?}", "Creating new buffer {} with text: {:?}",
buffer.id(), buffer.remote_id(),
buffer.read(cx).text() buffer.text()
); );
buffers.last().unwrap().clone() buffers.last().unwrap().clone()
} else { } else {
@ -1637,7 +1637,7 @@ impl MultiBuffer {
.collect::<Vec<_>>(); .collect::<Vec<_>>();
log::info!( log::info!(
"Inserting excerpts from buffer {} and ranges {:?}: {:?}", "Inserting excerpts from buffer {} and ranges {:?}: {:?}",
buffer_handle.id(), buffer_handle.read(cx).remote_id(),
ranges.iter().map(|r| &r.context).collect::<Vec<_>>(), ranges.iter().map(|r| &r.context).collect::<Vec<_>>(),
ranges ranges
.iter() .iter()
@ -1830,7 +1830,7 @@ impl MultiBufferSnapshot {
(start..end, word_kind) (start..end, word_kind)
} }
pub fn as_singleton(&self) -> Option<(&ExcerptId, usize, &BufferSnapshot)> { pub fn as_singleton(&self) -> Option<(&ExcerptId, u64, &BufferSnapshot)> {
if self.singleton { if self.singleton {
self.excerpts self.excerpts
.iter() .iter()
@ -2938,7 +2938,7 @@ impl MultiBufferSnapshot {
&self, &self,
offset: T, offset: T,
theme: Option<&SyntaxTheme>, theme: Option<&SyntaxTheme>,
) -> Option<(usize, Vec<OutlineItem<Anchor>>)> { ) -> Option<(u64, Vec<OutlineItem<Anchor>>)> {
let anchor = self.anchor_before(offset); let anchor = self.anchor_before(offset);
let excerpt_id = anchor.excerpt_id(); let excerpt_id = anchor.excerpt_id();
let excerpt = self.excerpt(excerpt_id)?; let excerpt = self.excerpt(excerpt_id)?;
@ -2978,7 +2978,7 @@ impl MultiBufferSnapshot {
} }
} }
pub fn buffer_id_for_excerpt(&self, excerpt_id: ExcerptId) -> Option<usize> { pub fn buffer_id_for_excerpt(&self, excerpt_id: ExcerptId) -> Option<u64> {
Some(self.excerpt(excerpt_id)?.buffer_id) Some(self.excerpt(excerpt_id)?.buffer_id)
} }
@ -3116,7 +3116,7 @@ impl History {
fn end_transaction( fn end_transaction(
&mut self, &mut self,
now: Instant, now: Instant,
buffer_transactions: HashMap<usize, TransactionId>, buffer_transactions: HashMap<u64, TransactionId>,
) -> bool { ) -> bool {
assert_ne!(self.transaction_depth, 0); assert_ne!(self.transaction_depth, 0);
self.transaction_depth -= 1; self.transaction_depth -= 1;
@ -3141,8 +3141,12 @@ impl History {
} }
} }
fn push_transaction<'a, T>(&mut self, buffer_transactions: T, now: Instant) fn push_transaction<'a, T>(
where &mut self,
buffer_transactions: T,
now: Instant,
cx: &mut ModelContext<MultiBuffer>,
) where
T: IntoIterator<Item = (&'a ModelHandle<Buffer>, &'a language::Transaction)>, T: IntoIterator<Item = (&'a ModelHandle<Buffer>, &'a language::Transaction)>,
{ {
assert_eq!(self.transaction_depth, 0); assert_eq!(self.transaction_depth, 0);
@ -3150,7 +3154,7 @@ impl History {
id: self.next_transaction_id.tick(), id: self.next_transaction_id.tick(),
buffer_transactions: buffer_transactions buffer_transactions: buffer_transactions
.into_iter() .into_iter()
.map(|(buffer, transaction)| (buffer.id(), transaction.id)) .map(|(buffer, transaction)| (buffer.read(cx).remote_id(), transaction.id))
.collect(), .collect(),
first_edit_at: now, first_edit_at: now,
last_edit_at: now, last_edit_at: now,
@ -3247,7 +3251,7 @@ impl Excerpt {
fn new( fn new(
id: ExcerptId, id: ExcerptId,
locator: Locator, locator: Locator,
buffer_id: usize, buffer_id: u64,
buffer: BufferSnapshot, buffer: BufferSnapshot,
range: ExcerptRange<text::Anchor>, range: ExcerptRange<text::Anchor>,
has_trailing_newline: bool, has_trailing_newline: bool,
@ -4715,7 +4719,7 @@ mod tests {
"Inserting excerpt at {} of {} for buffer {}: {:?}[{:?}] = {:?}", "Inserting excerpt at {} of {} for buffer {}: {:?}[{:?}] = {:?}",
excerpt_ix, excerpt_ix,
expected_excerpts.len(), expected_excerpts.len(),
buffer_handle.id(), buffer_handle.read(cx).remote_id(),
buffer.text(), buffer.text(),
start_ix..end_ix, start_ix..end_ix,
&buffer.text()[start_ix..end_ix] &buffer.text()[start_ix..end_ix]
@ -4801,8 +4805,8 @@ mod tests {
let mut excerpt_starts = excerpt_starts.into_iter(); let mut excerpt_starts = excerpt_starts.into_iter();
for (buffer, range) in &expected_excerpts { for (buffer, range) in &expected_excerpts {
let buffer_id = buffer.id();
let buffer = buffer.read(cx); let buffer = buffer.read(cx);
let buffer_id = buffer.remote_id();
let buffer_range = range.to_offset(buffer); let buffer_range = range.to_offset(buffer);
let buffer_start_point = buffer.offset_to_point(buffer_range.start); let buffer_start_point = buffer.offset_to_point(buffer_range.start);
let buffer_start_point_utf16 = let buffer_start_point_utf16 =

View file

@ -8,7 +8,7 @@ use sum_tree::Bias;
#[derive(Clone, Copy, Eq, PartialEq, Debug, Hash)] #[derive(Clone, Copy, Eq, PartialEq, Debug, Hash)]
pub struct Anchor { pub struct Anchor {
pub(crate) buffer_id: Option<usize>, pub(crate) buffer_id: Option<u64>,
pub(crate) excerpt_id: ExcerptId, pub(crate) excerpt_id: ExcerptId,
pub(crate) text_anchor: text::Anchor, pub(crate) text_anchor: text::Anchor,
} }

View file

@ -125,7 +125,7 @@ pub struct Project {
/// Used for re-issuing buffer requests when peers temporarily disconnect /// Used for re-issuing buffer requests when peers temporarily disconnect
incomplete_remote_buffers: HashMap<u64, Option<ModelHandle<Buffer>>>, incomplete_remote_buffers: HashMap<u64, Option<ModelHandle<Buffer>>>,
buffer_snapshots: HashMap<u64, HashMap<LanguageServerId, Vec<LspBufferSnapshot>>>, // buffer_id -> server_id -> vec of snapshots buffer_snapshots: HashMap<u64, HashMap<LanguageServerId, Vec<LspBufferSnapshot>>>, // buffer_id -> server_id -> vec of snapshots
buffers_being_formatted: HashSet<usize>, buffers_being_formatted: HashSet<u64>,
nonce: u128, nonce: u128,
_maintain_buffer_languages: Task<()>, _maintain_buffer_languages: Task<()>,
_maintain_workspace_config: Task<()>, _maintain_workspace_config: Task<()>,
@ -3204,9 +3204,11 @@ impl Project {
cx.spawn(|this, mut cx| async move { cx.spawn(|this, mut cx| async move {
// Do not allow multiple concurrent formatting requests for the // Do not allow multiple concurrent formatting requests for the
// same buffer. // same buffer.
this.update(&mut cx, |this, _| { this.update(&mut cx, |this, cx| {
buffers_with_paths_and_servers buffers_with_paths_and_servers.retain(|(buffer, _, _)| {
.retain(|(buffer, _, _)| this.buffers_being_formatted.insert(buffer.id())); this.buffers_being_formatted
.insert(buffer.read(cx).remote_id())
});
}); });
let _cleanup = defer({ let _cleanup = defer({
@ -3214,9 +3216,10 @@ impl Project {
let mut cx = cx.clone(); let mut cx = cx.clone();
let buffers = &buffers_with_paths_and_servers; let buffers = &buffers_with_paths_and_servers;
move || { move || {
this.update(&mut cx, |this, _| { this.update(&mut cx, |this, cx| {
for (buffer, _, _) in buffers { for (buffer, _, _) in buffers {
this.buffers_being_formatted.remove(&buffer.id()); this.buffers_being_formatted
.remove(&buffer.read(cx).remote_id());
} }
}); });
} }

View file

@ -60,7 +60,7 @@ pub trait Item: View {
style: &theme::Tab, style: &theme::Tab,
cx: &AppContext, cx: &AppContext,
) -> AnyElement<V>; ) -> AnyElement<V>;
fn for_each_project_item(&self, _: &AppContext, _: &mut dyn FnMut(usize, &dyn project::Item)) {} fn for_each_project_item(&self, _: &AppContext, _: &mut dyn FnMut(usize, &dyn project::Item)) {} // (model id, Item)
fn is_singleton(&self, _cx: &AppContext) -> bool { fn is_singleton(&self, _cx: &AppContext) -> bool {
false false
} }