-
-
Notifications
You must be signed in to change notification settings - Fork 101
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
VSCode Extension: Add diagnostics and code actions and format range #1376
Conversation
cdcc356
to
5ad7971
Compare
dda0595
to
6b7d239
Compare
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.
Hey, thanks for your contribution! It was a pretty neat idea to do the comparison in VSCode instead of CSharpier. It won't help for other IDE integrations, but I suppose this it better than nothing.
You mentioned that it fixes #659, but from looking through the code I only see a new code action provider being created.
Will this code make partial formats happen if
"editor.formatOnSaveMode": "modificationsIfAvailable"
is set?
If not, would you be able to make a simple change to add it?
Hey, apologies for the delay in responding.
Yes sorry, I have not thought about Format Selection. By providing a QuickFIx CodeAction it's possible to format only parts of the code. While not the same as formating selection it provides a similar feature: fix_part_code.movSaying that, I will investigate to see how complicated it'l be to support Format Selection.
At this time it doesn't support |
OK! With the latest change we can format selection. We generate the diff, then we compare the differences to check if they're in the range of the selection, and if so, apply the diff change as a TextEdit. format_selection.mov |
89e077f
to
f8256f3
Compare
Also, now that we can format within a range, format_modified.mov |
f8256f3
to
3556933
Compare
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.
LGTM. Thank you very much for your contribution!
@badsyntax thanks for implementing all of this! Sorry for the delay on releasing it, I published version 1.9.0 just now which contains the changes. |
@belav awesome. Code is pretty easy to follow imo but feel free to ping me for any modifications/support |
Fixes belav#1375 Fixes belav#659 A lot of this code has been taken from [one of my open source extensions](https://github.com/badsyntax/vscode-spotless-gradle). This approach uses the [prettier-linter-helpers](https://www.npmjs.com/package/prettier-linter-helpers) package to generate diffs of strings (unformatted code against formatted code) which is used to provide diagnostic information and code actions. This allows for formatting parts of code. <img width="1479" alt="Screenshot 2024-11-07 at 21 55 03" src="https://github.com/user-attachments/assets/93e643fc-91c6-4684-882f-3445128b7580"> <img width="547" alt="Screenshot 2024-11-07 at 22 26 38" src="https://github.com/user-attachments/assets/905cb8f6-87d7-499b-83ca-d470cc6e9d44"> --------- Co-authored-by: Richard Willis <[email protected]> Co-authored-by: Lasath Fernando <[email protected]>
Fixes #1375
Fixes #659
A lot of this code has been taken from one of my open source extensions.
This approach uses the prettier-linter-helpers package to generate diffs of strings (unformatted code against formatted code) which is used to provide diagnostic information and code actions. This allows for formatting parts of code.