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

Code Autocomplete Order Messed Up #2917

Closed
SansPapyrus683 opened this issue Feb 3, 2023 · 3 comments · Fixed by eclipse-jdtls/eclipse.jdt.ls#2439
Closed

Code Autocomplete Order Messed Up #2917

SansPapyrus683 opened this issue Feb 3, 2023 · 3 comments · Fixed by eclipse-jdtls/eclipse.jdt.ls#2439

Comments

@SansPapyrus683
Copy link

[provide a description of the issue]

Environment
  • Operating System: Windows 11
  • JDK version: 18
  • Visual Studio Code version: 1.75.0
  • Java extension version: 1.14.0
Steps To Reproduce
  1. Install the extension
  2. Use code autocomplete
Current Result

Right now, this is what shows up in the code autocomplete:
image

Expected Result

I expected the starred completion (parseInt() without any arguments) to show up at the top, but for some reason it's at the bottom.

@jdneo
Copy link
Collaborator

jdneo commented Feb 7, 2023

The response returned from LS is:

[Trace - 3:48:43 PM] Received response 'textDocument/completion - (68)' in 54ms.
Result: {
    "isIncomplete": false,
    "items": [
        {
            "label": "★ parseInt(String s) : int",
            "kind": 2,
            "detail": "Integer.parseInt(String s) : int",
            "sortText": "999997579",
            "insertText": "parseInt",
            ...
        },
        {
            "label": "★ parseInt(String s, int radix) : int",
            "kind": 2,
            "detail": "Integer.parseInt(String s, int radix) : int",
            "sortText": "999997835",
            "insertText": "parseInt",
            ...
        },
        {
            "label": "parseInt(CharSequence s, int beginIndex, int endIndex, int radix) : int",
            "kind": 2,
            "detail": "Integer.parseInt(CharSequence s, int beginIndex, int endIndex, int radix) : int",
            "sortText": "999999179",
            "insertText": "parseInt",
            ...
        },
        {
            "label": "parseUnsignedInt(CharSequence s, int beginIndex, int endIndex, int radix) : int",
            "kind": 2,
            "detail": "Integer.parseUnsignedInt(CharSequence s, int beginIndex, int endIndex, int radix) : int",
            "sortText": "999999179",
            "insertText": "parseUnsignedInt",
            ...
        },
        {
            "label": "parseUnsignedInt(String s, int radix) : int",
            "kind": 2,
            "detail": "Integer.parseUnsignedInt(String s, int radix) : int",
            "sortText": "999999179",
            "insertText": "parseUnsignedInt",
            ...
        },
        {
            "label": "parseUnsignedInt(String s) : int",
            "kind": 2,
            "detail": "Integer.parseUnsignedInt(String s) : int",
            "sortText": "999999179",
            "insertText": "parseUnsignedInt",
            ...
        }
    ]
}

It's strange because from my understanding, The sort text "999997579" should make it rank higher than "999999179", but the actual order is not in that way.

@Eskibear, do you have any idea about this?

@jdneo jdneo added the bug label Feb 7, 2023
@Eskibear
Copy link
Contributor

Eskibear commented Feb 7, 2023

If filterText is not defined, it will fallback to use label. Here it's better to explicitly set filterText to what's in insertText.

@rgrunber
Copy link
Member

rgrunber commented Feb 7, 2023

Yup, this seems to be what https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionItem indicates. Just wanted to make sure the change can be justified directly from what the spec says.

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

Successfully merging a pull request may close this issue.

4 participants