mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2026-03-24 20:40:30 +00:00
Merge pull request #21770 from Wilfred/vfs_remove_events
fix: Update VFS when a watched file is deleted
This commit is contained in:
@@ -208,6 +208,22 @@ impl NotifyActor {
|
||||
)
|
||||
})
|
||||
.filter_map(|path| -> Option<(AbsPathBuf, Option<Vec<u8>>)> {
|
||||
// Ignore events for files/directories that we're not watching.
|
||||
if !(self.watched_file_entries.contains(&path)
|
||||
|| self
|
||||
.watched_dir_entries
|
||||
.iter()
|
||||
.any(|dir| dir.contains_file(&path)))
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
// For removed files, fs::metadata() will return Err, but
|
||||
// we still want to update the VFS.
|
||||
if matches!(event.kind, EventKind::Remove(_)) {
|
||||
return Some((path, None));
|
||||
}
|
||||
|
||||
let meta = fs::metadata(&path).ok()?;
|
||||
if meta.file_type().is_dir()
|
||||
&& self
|
||||
@@ -223,15 +239,6 @@ impl NotifyActor {
|
||||
return None;
|
||||
}
|
||||
|
||||
if !(self.watched_file_entries.contains(&path)
|
||||
|| self
|
||||
.watched_dir_entries
|
||||
.iter()
|
||||
.any(|dir| dir.contains_file(&path)))
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
let contents = read(&path);
|
||||
Some((path, contents))
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user