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

C# LSP Regex completion does not work as expected. #59545

Closed
NTaylorMullen opened this issue Feb 14, 2022 · 7 comments
Closed

C# LSP Regex completion does not work as expected. #59545

NTaylorMullen opened this issue Feb 14, 2022 · 7 comments
Assignees
Labels
Area-IDE Bug LSP issues related to the roslyn language server protocol implementation Resolution-Duplicate The described behavior is tracked in another issue

Comments

@NTaylorMullen
Copy link
Contributor

Version Used:

Steps to Reproduce:

  1. Enable C# LSP feature flag
  2. Try and commit any sort of Regex completion item

For instance:
devenv_g0v6pLWNfP

Expected Behavior: commit works as expected

Actual Behavior: Extra content is duplicated / labels seem to apply? Gif is kinda long but shows a lot.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 14, 2022
@sharwell sharwell added Bug LSP issues related to the roslyn language server protocol implementation labels Feb 16, 2022
@jinujoseph jinujoseph removed the untriaged Issues and PRs which have not yet been triaged by a lead label Feb 16, 2022
@jinujoseph jinujoseph added this to the 17.2 milestone Feb 16, 2022
@CyrusNajmabadi
Copy link
Member

@NTaylorMullen @dibarbet how does completion work in LSP? Does it not use the data in roslyn's completion items?

@dibarbet
Copy link
Member

dibarbet commented Feb 18, 2022

@CyrusNajmabadi we convert the Roslyn completion item to the LSP completion item. I could imagine something going wrong here - https://sourceroslyn.io/#Microsoft.CodeAnalysis.EditorFeatures/Implementation/LanguageServer/Handlers/Completion/CompletionHandler.cs,209

LSP first looks at the textEdit of the completion item, if it exists it uses that. If no text edit, it will use the insertText to commit. If that doesn't exist, it uses the label.

Just guessing, but potentially it's using the label to commit incorrectly?

@CyrusNajmabadi
Copy link
Member

Yes. That seems buggy. It should be using LSPCompletionProvider.GetChangeAsync to determine what actual change should be made.

@dibarbet
Copy link
Member

@CyrusNajmabadi note there are potential perf issues with providing text edits instead of insert text - @allisonchou how far did we get in the experiment to always provide text edits in completion? Did it end up being bad for perf?

@CyrusNajmabadi
Copy link
Member

Our completio API has no concept of 'insertion text'. If we want to try to have logic htat finds that special data, it must only do so on providers where that is safe. e.g. the provider (or item) needs to opt into that in some way. If it doesn't, we need to fallback to using the actual API we have for computing the change. otherwise, we're just going to get this wrong :)

@allisonchou
Copy link
Contributor

allisonchou commented Feb 18, 2022

We likely want to implement this work item before turning TextEdits on by default - dotnet/razor#4408
I recall TextEdits making completion perf noticeably slower, the above task should help speed things up. It requires work in both Roslyn and the LSP client however.

@dibarbet dibarbet added the Resolution-Duplicate The described behavior is tracked in another issue label Mar 14, 2022
@dibarbet
Copy link
Member

tracking this in #59773

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Bug LSP issues related to the roslyn language server protocol implementation Resolution-Duplicate The described behavior is tracked in another issue
Projects
None yet
Development

No branches or pull requests

6 participants