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

[Bug] Improve soft selection in completion #7977

Open
dibarbet opened this issue Feb 7, 2025 · 1 comment
Open

[Bug] Improve soft selection in completion #7977

dibarbet opened this issue Feb 7, 2025 · 1 comment
Assignees
Milestone

Comments

@dibarbet
Copy link
Member

dibarbet commented Feb 7, 2025

In the following gif, the item should either not be present (because App is considered filter text), or should be in soft selection (no exact match).

However

  1. In VSCode, we do not get callbacks for filtering. So if the item is originally hard selected, we cannot change to soft selection once the list is filtered down that much.
  2. In VS, it looks like we consider 'App' as part of the completion item, but not in VSCode. Potentially we need to up[date what we consider as part of the filter text.

Image

@dibarbet dibarbet self-assigned this Feb 7, 2025
@dibarbet dibarbet added this to the Feb2025 milestone Feb 7, 2025
@dibarbet dibarbet added the Bug label Feb 7, 2025
@dibarbet
Copy link
Member Author

I took a look at this today. There are a couple of differences when compared to VS.

  1. In VS, completion does not show up at all when typing in front of App inside the <.
  2. In VS, if you explicitly invoke completion (cntrl+space) when typing in front of App, completion shows up with an initial soft selection. If you start typing Project, ProjectResourceBuilderExtensions will be hard selected and committed if you type .. If you continue typing and type Projects, the item for ProjectResourceBuilderExtensions becomes soft selected, and will not be commited with ..

Unfortunately, VSCode has some limitations here that make the behavior here difficult to match VS.

  1. The difference in completion showing up appears to be down to how completion is triggered. VSCode does not distinguish between invocation by typing a word character, and manual invocation via the keybind (cntrl+space). Both are classified as Invoked. VS does distinguish and so is able to provide different behavior for the typing scenario.
  2. The difference in hard/soft selection updating is caused by a couple different limitations in VSCode
    a. There is no soft selection in VSCode. We can only emulate it by adding or removing trigger characters (which we do).
    b. VSCode does partial matching on the filter text (as long as the typed char matches somewhere after in the filter text, completion stays up).
    b. VSCode does not call us back on list update, or commit. We only provide the list upfront. So when further typing happens that makes an item no longer fully match, we don't switch to soft selection (like we do in VS).

There's a couple of ways we may be able to make this better, but nothing extremely simple

  1. Have VSCode distinguish between typing a word char and manual invocation. Then we can simply not show completion here like we do in VS.
  2. Implement filtering and selection behavior entirely on the server side using the isIncomplete flag. This means the server gets a callback for every character typed and can manually adjust what items show in the list and what commit characters they have. However this is slower as we have to roundtrip to the server on every typed character.

My preference is 1), but requires work on the VSCode side to add the new kind (issue link TBD).

I would like to also point out that TypeScript in VSCode has the same behavior. So this is not unique to our extension:

Image

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

1 participant