Change:
<!-- Do Not Delete This! bugreporttemplate --<!-- Please read our Rules of Conduct: --<!-- Read our guide about submitting issues: --<!-- Search existing issues to avoid creating duplicates. --<!-- Test using the latest Insiders build to see if your issue has already been fixed: --<!-- Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. --<!-- Launch with to check. --Does this issue occur when all extensions are disabled?: Yes VS Code Version: main branch () OS Version: any Sorting of suggestions is broken if the CompletionItem uses label details. When is a string, suggestions are sorted by label with ties broken by the completion item kind. But if is a then it is not sorted correctly. Here's the bug: This doesn't work as intended on objects. when and are both objects, these two comparisons BOTH return false and things end up being sorted only by kind. if one label is a string and the other is a , then the string ends up sorted after the no matter what the 's label is. Steps to Reproduce: a that returns something like this: end up sorted d, c, b, a, z but should be a, b, c, d, z
Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.68.1. Please try upgrading to the latest version and checking whether this issue remains. Happy Coding!
fix is to use I think
Thanks This is a nice bug and good find. You did a great investigation, planning to fix this in this milestone but since you already did the lead work I'll happily review a PR from you
<!-- AUTHORVERIFICATIONREQUEST --This bug has been fixed in the latest release of ! you can help us out by commenting if things are now working as expected. If things still don't seem right, please ensure you're on version of Insiders (today's or later - you can use in the command palette to check), and leave a comment letting us know what isn't working as expected. Happy Coding!

Discussion:
} } // check with 'label' <del> if (a.completion.label < b.completion.label) { </del> <ins> if (a.textLabel < b.textLabel) { </ins> return -1; <del> } else if (a.completion.label > b.completion.label) { </del> <ins> } else if (a.textLabel > b.textLabel) { </ins> return 1; } // check with 'type'

import { CompletionItem, getSuggestionComparator, SnippetSortOrder } from 'vs/editor/contrib/suggest/browser/suggest'; import { WordDistance } from 'vs/editor/contrib/suggest/browser/wordDistance'; <del> export function createSuggestItem(label: string, overwriteBefore: number, kind = languages.CompletionItemKind.Property, incomplete: boolean = false, position: IPosition = { lineNumber: 1, column: 1 }, sortText?: string, filterText?: string): CompletionItem { </del> <ins> export function createSuggestItem(label: string | languages.CompletionItemLabel, overwriteBefore: number, kind = languages.CompletionItemKind.Property, incomplete: boolean = false, position: IPosition = { lineNumber: 1, column: 1 }, sortText?: string, filterText?: string): CompletionItem { </ins> const suggestion: languages.CompletionItem = { label, sortText, filterText, range: { startLineNumber: position.lineNumber, startColumn: position.column - overwriteBefore, endLineNumber: position.lineNumber, endColumn: position.column }, <del> insertText: label, </del> <ins> insertText: typeof label === 'string' ? label : label.label, </ins> kind }; const container: languages.CompletionList = {

assert.strictEqual(second.completion.label, '<- groups'); }); <ins> test('Completion item sorting broken when using label details #153026', function () { const itemZZZ = createSuggestItem({ label: 'ZZZ' }, 0, languages.CompletionItemKind.Operator, false); const itemAAA = createSuggestItem({ label: 'AAA' }, 0, languages.CompletionItemKind.Operator, false); const itemIII = createSuggestItem('III', 0, languages.CompletionItemKind.Operator, false); const cmp = getSuggestionComparator(SnippetSortOrder.Inline); const actual = [itemZZZ, itemAAA, itemIII].sort(cmp); assert.deepStrictEqual(actual, [itemAAA, itemIII, itemZZZ]); }); </ins> test('Score only filtered items when typing more, score all when typing less', function () { model = new CompletionModel([ createSuggestItem('console', 0),