-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid syntax error notification for source code actions #12148
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code changes look good, but I'm not sure if we want to keep some indicator to why the action failed?
Let's say you have a very long document and the syntax error is outside the visible area. It might now be unclear to users why the manually triggered action does nothing.
RustRover does show an error when running rustfmt
failed because of a syntax error and I find this useful information.
That is interesting. Does it show on every save? I don't mind providing a notification. |
Only when I issue the Reformat code manually. It doesn't show a notification when the formatting on save fails. |
I think it's difficult for a language server to know whether something was invoked manually or automatically by the client except for code actions for which there's I guess RustRover is able to do this reliably because the entire stack is in their control. |
I've opened #12176 for now and I can tackle it later. |
Summary
This PR avoids the error notification if a user selects the source code actions and there's a syntax error in the source.
Before #12134, the change would've been different. But that PR disables generating fixes if there's a syntax error. This means that we can return an empty map instead as there won't be any fixes in the diagnostics returned by the
lint_fix
function.For reference, following are the screenshot as on
main
with the error:VS Code:
Neovim:
fixes: #11931
Test Plan
Considering the following code snippet where there are two diagnostics (syntax error and useless semicolon
E703
):VS Code
Screen.Recording.2024-07-02.at.16.42.29.mov
Neovim
Screen.Recording.2024-07-02.at.16.41.24.mov