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

Completion: Improve behavior for pre-selecting options #8295

Open
ryanbrandenburg opened this issue Feb 17, 2023 · 3 comments
Open

Completion: Improve behavior for pre-selecting options #8295

ryanbrandenburg opened this issue Feb 17, 2023 · 3 comments

Comments

@ryanbrandenburg
Copy link
Contributor

Some suggestions that were broadly agreed with:

  1. "<dalog" should include a completion for "dialog" (but does not today). Cyrus specifically wrote this in Roslyn to be a linear scan of the word so it should be cheap.
  2. "<dv" should include a completion for "div". This is really just a subset of the above item, but there is some special casing about length so we should verify it separately. There is also a behavior difference between cshtml and razor files here which it would be good to smooth over.
    1. The behavior here should be consistent between Roslyn (non-LSP) and the LSP client, so if and when the LSP Client makes an update for this Roslyn needs to be notified so they can do a fast follow/simultaneous insertion.
  3. Matching should prefer a case-sensitive matching. IE, "<d" should select "<datalist" before it selects "<DataAnnotations". (it does the reverse right now).

Where we did not find firm opinions was around when Razor should and should not be in "Suggestion Mode". Roslyn enters Suggestion Mode whenever both existing options and "random" new options are legal. This is unfortunately the case any time you type "<" in a Razor file because html allows undefined tags (and you may be typing a Razor tag you haven't created yet), so following that rule would result in suggestion mode always being on for Razor.

To quote @jimmylewis though: "Using the VS telemetry monitor for the LSP messages in the <dv scenario, there is only one completion request sent when < is typed, and the rest are completionItem/resolve requests as the filtering is applied. Order here is not linear because the app tries to group request/response pairs, but you can see that each server only gets one textDocument/completion request for the whole 3-keystroke interaction. The rest of the behavior (filtering, selection) is done purely on the client using that first completion list."

To re-state, this means that changes to the behavior for #1 and #2 (and #3 if I understand the scenario correctly) would have to come from the LSP client and would therefore affect all Language Servers.

@ghost ghost added the untriaged label Feb 17, 2023
@davidwengier
Copy link
Member

I think we should do a spike and remove space from being a commit character for any html completion item and see how it feels. At least we're in charge of that scenario :)

@jimmylewis
Copy link
Contributor

If you remove space from being a commit character, you should make sure it dismisses the completion session. Otherwise if the session stays open you can keep typing out a full tag e.g. <div class="foo"> (best partial match/selected completion is still "div") and the next trigger character (e.g. >) will commit the completion item, which replaces the full completion session span and gives you just <div>.

@davidwengier
Copy link
Member

If you remove space from being a commit character, you should make sure it dismisses the completion session

It does!

davidwengier added a commit that referenced this issue Oct 9, 2023
Resolves the "we did not find firm opinions" part of
#8295 by introducing an option to
allow users to control how they want completion for html elements, tag
helper elements and components to behave.

Corresponding VS Code PR:
dotnet/vscode-csharp#6506
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants