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

Exact match in completion overrides CompletionItem.sortText #101254

Closed
renkun-ken opened this issue Jun 29, 2020 · 4 comments
Closed

Exact match in completion overrides CompletionItem.sortText #101254

renkun-ken opened this issue Jun 29, 2020 · 4 comments
Assignees
Labels
*as-designed Described behavior is as designed

Comments

@renkun-ken
Copy link

  • VSCode Version: 1.46.1
  • OS Version: macOS 10.15.5

The completion items provider of a language server could specify CompletionItem.sortText (as defined in https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_completion) to adjust the order of completion items. However, exact match in the completion list overrides the ordering specified by CompletionItem.sortText.

For example, the completion items are

label (sortText)
---------------
test (0-test)
tes  (1-tes)

If user types tes, both completion items appear but tes, as an exact match of current input, ranks higher than test even though test should rank higher in terms of its sortText.

Related:

@jrieken jrieken added the *as-designed Described behavior is as designed label Jun 30, 2020
@jrieken
Copy link
Member

jrieken commented Jun 30, 2020

That's the design. What a user types (the prefix) always counts more than what the extension wants

@renkun-ken
Copy link
Author

In the example at REditorSupport/languageserver#288, the user is inputing the following function call:

sample(1, 1, rep|

where | stands for the cursor. While there's a function named rep, we actually want sample's argument replace to always rank higher than other symbols in this case.

In fact, we want to implement a principle to give different priorities to different category of completion items: from local to global. Is there a way we could ensure that some completion items always rank higher than others even if the current token under cursor has an exact match (which is in most cases not desired)?

@HaoboGu
Copy link
Contributor

HaoboGu commented Jul 10, 2020

That's the design. What a user types (the prefix) always counts more than what the extension wants

I don't think this is a good design, look at the following example:
image

I have already typed Test, the suggestion of Test is meaningless: nothing will happen if I choose Test.

So I think the prefix matching, at least the exact matching(the suggestion is exact same as the prefix) should not override the sortText.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*as-designed Described behavior is as designed
Projects
None yet
Development

No branches or pull requests

4 participants
@jrieken @renkun-ken @HaoboGu and others