fix: Incorrect flychecks with multiple workspaces#21709
Open
Wilfred wants to merge 1 commit intorust-lang:masterfrom
Open
fix: Incorrect flychecks with multiple workspaces#21709Wilfred wants to merge 1 commit intorust-lang:masterfrom
Wilfred wants to merge 1 commit intorust-lang:masterfrom
Conversation
This comment has been minimized.
This comment has been minimized.
9638c64 to
0960ec2
Compare
This comment has been minimized.
This comment has been minimized.
Contributor
Author
|
Interesting, a macOS test is hanging due to no diagnostics. That sounds like #21571. |
0960ec2 to
08e9bcd
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Contributor
Author
|
I can't reproduce the macOS failure on my mac laptop, I presume this is just a performance with GitHub's macOS CI. I've tweaked the timeouts, but as mentioned above I think a fix similar to #21571 is going to help, so I'll look at that too. |
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
rust-lang#21666), but that just meant a race condition
when events arrive in the opposite order.
08e9bcd to
2b438d7
Compare
Collaborator
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Contributor
Author
|
OK, I've removed the integration test here as it's flaky. I think the logic is obviously correct -- it now matches the comment -- and it fixes the issue I'm seeing in my local testing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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 arrived in the opposite order.