Skip to content

fix: File watcher should watch directories recursively#21771

Open
Wilfred wants to merge 1 commit intorust-lang:masterfrom
Wilfred:watch_dirs_recursively
Open

fix: File watcher should watch directories recursively#21771
Wilfred wants to merge 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants