Skip to content

Commit 56a074b

Browse files
committed
fix: File watcher should watch directories recursively
Currently rust-analyzer only watches the directory itself, and doesn't consider children recursively. This is a problem when the directory itself is deleted and recreated (e.g. if you're creating all of `mycrate/src/` with a code generating script). The obvious solution is to configure rust-analyzer to watch the parent directory (assuming rust-project.json), but that requires recursive watching. This problem probably also occurs when switching between git commits. Instead, watch directories recursively so we can use the file watcher with parent directories. See also discussion on rust-lang/rust-analyzer#19907. I've tested on some decent sized projects (several hundred transitive dependencies) and performance seemed fine.
1 parent 45efcf5 commit 56a074b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

  • src/tools/rust-analyzer/crates/vfs-notify/src

src/tools/rust-analyzer/crates/vfs-notify/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ impl NotifyActor {
317317

318318
fn watch(&mut self, path: &Path) {
319319
if let Some((watcher, _)) = &mut self.watcher {
320-
log_notify_error(watcher.watch(path, RecursiveMode::NonRecursive));
320+
log_notify_error(watcher.watch(path, RecursiveMode::Recursive));
321321
}
322322
}
323323

0 commit comments

Comments
 (0)