Skip to content

fix: File watcher should watch directories recursively#21771

Merged
Veykril merged 1 commit intorust-lang:masterfrom
Wilfred:watch_dirs_recursively
Mar 10, 2026
Merged

fix: File watcher should watch directories recursively#21771
Veykril merged 1 commit intorust-lang:masterfrom
Wilfred:watch_dirs_recursively

Conversation

@Wilfred
Copy link
Contributor

@Wilfred Wilfred commented Mar 6, 2026

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 #19907.

I've tested on some decent sized projects (several hundred transitive dependencies) and performance seemed fine.

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#19907. I've tested on some decent sized projects (several hundred transitive dependencies) and performance seemed fine.
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 6, 2026
Copy link
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see how this goes

View changes since this review

@Veykril Veykril added this pull request to the merge queue Mar 10, 2026
Merged via the queue into rust-lang:master with commit 3e832f3 Mar 10, 2026
17 of 18 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 10, 2026
@Wilfred Wilfred deleted the watch_dirs_recursively branch March 12, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants