Avoid syntax error notification for source code actions#12148
Avoid syntax error notification for source code actions#12148dhruvmanila merged 1 commit intomainfrom
Conversation
|
MichaReiser
left a comment
There was a problem hiding this comment.
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_fixfunction.For reference, following are the screenshot as on
mainwith 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