Commit 2b438d7
committed
fix: Incorrect flychecks with multiple workspaces
When rust-analyzer receives textDocument/didChangeWatchedFiles, we
want to trigger a flycheck in all workspaces if we can't find which
workspace owns those files.
However, since we used .any() instead of .all(), this behaviour was
always triggered when the user had more than one workspace.
Instead, use .all() so we correctly detect when the file it outside of
all workspaces.
---
For cargo-based projects, this just made rust-analyzer slower. For
projects with a custom check command using $saved_file or
{saved_file}, this introduced a race condition that sometimes
prevented diagnostics.
When we see the following flycheck events in this order:
// Created by textDocument/didSave.
RequestStateChange(Restart { ... saved_file: Some("foo.rs") })
// Created by textDocument/didChangeWatchedFiles
RequestStateChange(Restart { ... saved_file: None })
Then the flycheck debounce takes the last event, we invoke flycheck
with saved_file: None, and no flycheck occurs (because we require a
value to substitute in $saved_file).
Previously the debounce took the first event (until
#21666), but that just meant a race condition
when events arrive in the opposite order.1 parent a8e2add commit 2b438d7
2 files changed
Lines changed: 3 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1021 | 1021 | | |
1022 | 1022 | | |
1023 | 1023 | | |
1024 | | - | |
| 1024 | + | |
1025 | 1025 | | |
1026 | 1026 | | |
1027 | 1027 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
| 298 | + | |
298 | 299 | | |
299 | | - | |
| 300 | + | |
300 | 301 | | |
301 | 302 | | |
302 | 303 | | |
| |||
0 commit comments