Fix race-condition in autosave (#39409)
This removes a long-standing thing we've done, which is send a `DidSave` notification to the language server for the clean parts of a multi-buffer. However, it seems like the intent of that notification is to tell the language server to reload the file from disk. As we didn't actually write those files to disk, it seems clearer to not send this notification; and just remove this whole code-path. Release Notes: - Fixed a race where autosave in a multibuffer could cause unsaved buffers to appear saved
This commit is contained in:
@@ -832,12 +832,11 @@ impl Item for Editor {
|
||||
|
||||
// let mut buffers_to_save =
|
||||
let buffers_to_save = if self.buffer.read(cx).is_singleton() && !options.autosave {
|
||||
buffers.clone()
|
||||
buffers
|
||||
} else {
|
||||
buffers
|
||||
.iter()
|
||||
.into_iter()
|
||||
.filter(|buffer| buffer.read(cx).is_dirty())
|
||||
.cloned()
|
||||
.collect()
|
||||
};
|
||||
|
||||
@@ -863,22 +862,6 @@ impl Item for Editor {
|
||||
.await?;
|
||||
}
|
||||
|
||||
// Notify about clean buffers for language server events
|
||||
let buffers_that_were_not_saved: Vec<_> = buffers
|
||||
.into_iter()
|
||||
.filter(|b| !buffers_to_save.contains(b))
|
||||
.collect();
|
||||
|
||||
for buffer in buffers_that_were_not_saved {
|
||||
buffer
|
||||
.update(cx, |buffer, cx| {
|
||||
let version = buffer.saved_version().clone();
|
||||
let mtime = buffer.saved_mtime();
|
||||
buffer.did_save(version, mtime, cx);
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user