Wait with change processing until the vfs is done

This commit is contained in:
Lukas Wirth 2024-08-02 17:09:25 +02:00
parent 8286847bee
commit c6ae9cde99
5 changed files with 34 additions and 30 deletions

View file

@ -201,8 +201,8 @@ impl Vfs {
pub fn set_file_contents(&mut self, path: VfsPath, contents: Option<Vec<u8>>) -> bool {
let _p = span!(Level::INFO, "Vfs::set_file_contents").entered();
let file_id = self.alloc_file_id(path);
let state = self.get(file_id);
let change_kind = match (state, contents) {
let state: FileState = self.get(file_id);
let change = match (state, contents) {
(FileState::Deleted, None) => return false,
(FileState::Deleted, Some(v)) => {
let hash = hash_once::<FxHasher>(&*v);
@ -225,7 +225,7 @@ impl Vfs {
};
};
let changed_file = ChangedFile { file_id, change: change_kind };
let changed_file = ChangedFile { file_id, change };
match self.changes.entry(file_id) {
// two changes to the same file in one cycle, merge them appropriately
Entry::Occupied(mut o) => {