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 sortText and preselect is ignored when typed identifier is an exact match with completion label #71660

Closed
olafurpg opened this issue Apr 3, 2019 · 6 comments
Assignees
Labels
suggest IntelliSense, Auto Complete under-discussion Issue is under discussion for relevance, priority, approach

Comments

@olafurpg
Copy link

olafurpg commented Apr 3, 2019

  • VSCode Version: 1.32.3
  • OS Version: macOS Mojave 10.14.2 (18C54)

Steps to Reproduce:

  • run completion in the following Scala code using the Metals language server extension
  locally {
    val concurrentString = ""
    concurrent<COMPLETE>
  }
  • language server returns the following (simplified) completion items
[
    {
      "label": "concurrentString: String",
      "preselect": true,
      "sortText": "00000"
    },
    {
      "label": "concurrent",
      "sortText": "00001"
    }
  ]
  • I expected the concurrentString item to be pre-selected and appear at the top of the completion results
  • VS Code pre-selects the concurrent result even if it has a lower sortText

Screenshot 2019-04-03 at 15 49 40

Even if concurrent is an exact match with the typed identifier, I think it's undesirable to move it to the top because

  • the language server has semantic understanding about the program and knows that the local variable concurrentString is more likely to be selected
  • since I have already typed concurrent in the code, I don't save keystrokes by selecting concurrent.

Does this issue occur when all extensions are disabled?: No, you need the Metals language server extension.

@olafurpg olafurpg changed the title Completion sortText and preselect is ignored whe Completion sortText and preselect is ignored when typed identifier is an exact match with completion label Apr 3, 2019
@olafurpg
Copy link
Author

olafurpg commented Apr 3, 2019

I'm experiencing a similar issue where sortText is ignored even when the typed identifier is not an exact match with the label/filterText

Screenshot 2019-04-03 at 20 47 10

I expected the order to be [intNumber, toInt, instance] because the returned completion list gives toInt a lower sortText than instance

[
  {
    "label": "intNumber: Int",
    "preselect": true,
    "sortText": "00000",
    "filterText": "intNumber"
  },
  {
    "label": "toInt: Int",
    "sortText": "00001",
    "filterText": "toInt"
  },
  {
    "label": "instance: Int",
    "sortText": "00002",
    "filterText": "instance"
  },
  {
    "label": "asInstanceOf[T0]: T0",
    "sortText": "00003",
    "filterText": "asInstanceOf"
  },
  {
    "label": "isInstanceOf[T0]: Boolean",
    "sortText": "00004",
    "filterText": "isInstanceOf"
  }
]

@jrieken jrieken added suggest IntelliSense, Auto Complete under-discussion Issue is under discussion for relevance, priority, approach labels Apr 4, 2019
@jrieken
Copy link
Member

jrieken commented Apr 4, 2019

Yes, that's the design and honestly unlikely to change. The match-score with the current prefix (which the user typed) is stronger than the preselect property that the language brain computed. Only with equal scores, preselect comes to play. The reasoning is that user-input is worth more and I still think that's a good idea.

@jrieken
Copy link
Member

jrieken commented Apr 4, 2019

Commenting on the other question here: the same is true for sort text, that's used for the initial (prefix-less) sorting and to resolve score-conflicts but not to overrule user-input.

@olafurpg
Copy link
Author

olafurpg commented Apr 4, 2019

Thank you for the explanation. I agree the current behavior is a good default.

Would it be possible to introduce an option similar to editor.suggestSelection to disable the match-score based on the current prefix? For example editor.completionSort = "prefix-match-score" | "sort-text". In our extension, we can overwrite that setting for the Scala language while keeping the default for other languages.

In the examples above, I hadn't typed additional characters after triggering the completion so the language server sees the same user-input as VS Code.

Either way, I'm fine closing this ticket with "working as intended". This is not a critical issue, the completion experience in VS Code is already one of the best I have experienced 👏

@olafurpg
Copy link
Author

olafurpg commented Apr 8, 2019

Closing since this is unlikely to change, thank you for the explanation!

@olafurpg olafurpg closed this as completed Apr 8, 2019
@jrieken
Copy link
Member

jrieken commented Apr 9, 2019

Alright, there is an issue which is about disabling fuzzy scoring and using something more 'traditional' like prefix match. I didn't find it right away but that then might be interesting for you

@vscodebot vscodebot bot locked and limited conversation to collaborators May 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
suggest IntelliSense, Auto Complete under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

No branches or pull requests

2 participants