Skip to content
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

Fix bad completion commit in vs code #11398

Merged
merged 4 commits into from
Jan 22, 2025

Conversation

alexgav
Copy link
Contributor

@alexgav alexgav commented Jan 16, 2025

Summary of the changes

We need to avoid specifying explicit commit characters in VS Code as there is no soft selection and typing when completion list is up is much more likely to commit wrong items. This is especially true when commit characters are specified explicitly in some Razor completion items to work around some of the VS completion quirks. We can do so by defining a new flag and passing it from VS Code to rzls to specify the desired commit character set.

There will be a corresponding PR in VS Code to actually pass the new flag.

Fixes:
#10601

@alexgav alexgav requested a review from a team as a code owner January 16, 2025 22:28
@alexgav alexgav changed the title Dev/alexgav/fix bad completion commit in vs code Fix bad completion commit in vs code Jan 16, 2025
Copy link
Member

@DustinCampbell DustinCampbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to avoid specifying explicit commit characters in VS Code as there is no soft selection and typing when completion list is up is much more likely to commit wrong items.

Is there a more in-depth explanation of what is going wrong? Per-CompletionItem commit characters are part of the LSP spec and VS Code supports them, so I'd like to understand why VS Code is broken by them. Also, did this work in the past and was only recently broken in VS Code? If so, do we know why?

@alexgav
Copy link
Contributor Author

alexgav commented Jan 17, 2025

Is there a more in-depth explanation of what is going wrong? Per-CompletionItem commit characters are part of the LSP spec and VS Code supports them, so I'd like to understand why VS Code is broken by them. Also, did this work in the past and was only recently broken in VS Code? If so, do we know why?

This became an issue after my work to switch VSCode from legacy completion endpoint to the VS completion endpoint. Dan filed the bug a few months ago and I apparently missed it until you mentioned it recently in a meeting. VS Code does support per-item commit characters, that part is not a problem. The specific commit character causing an issue here is forward slash. If you type <ComponentName and then a space, attribute completion comes up, including the "@..." as the first item. VSCode appears to always have "hard selection" on the first item (unless better match is available). So at this point typing forward slash (to self-close the tag) commits the selected item, and you end up with <ComponentName @/ in your document. I don't see a way to fix this other than not have forward slash as the commit character. Since the comments in the DirectiveAttributeTransitionCompletionItemProvider indicate that explicit completion characters were provided only to work around the VS completion list behavior, I decided not to add them for the VS Code client. That makes VS Code use the same commit character set for all items (">=;") and this fixes the issue (in combination with another fix I have out for PR where we don't aggressively trigger completion in space in VS code, but even if you trigger completion manually with Ctrl+Space this will still not commit on forward slash anymore).

@DustinCampbell
Copy link
Member

This became an issue after my work to switch VSCode from legacy completion endpoint to the VS completion endpoint. Dan filed the bug a few months ago and I apparently missed it until you mentioned it recently in a meeting. VS Code does support per-item commit characters, that part is not a problem. The specific commit character causing an issue here is forward slash. If you type <ComponentName and then a space, attribute completion comes up, including the "@..." as the first item. VSCode appears to always have "hard selection" on the first item (unless better match is available). So at this point typing forward slash (to self-close the tag) commits the selected item, and you end up with <ComponentName @/ in your document. I don't see a way to fix this other than not have forward slash as the commit character. Since the comments in the DirectiveAttributeTransitionCompletionItemProvider indicate that explicit completion characters were provided only to work around the VS completion list behavior, I decided not to add them for the VS Code client. That makes VS Code use the same commit character set for all items (">=;") and this fixes the issue (in combination with another fix I have out for PR where we don't aggressively trigger completion in space in VS code, but even if you trigger completion manually with Ctrl+Space this will still not commit on forward slash anymore).

Thanks! That explanation is very helpful!

Copy link
Contributor

@ryzngard ryzngard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! One suggestion about naming but it's minor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants