@@ -10,13 +10,13 @@ import { CompletionModel } from 'vs/editor/contrib/suggest/browser/completionMod
10
10
import { CompletionItem , getSuggestionComparator , SnippetSortOrder } from 'vs/editor/contrib/suggest/browser/suggest' ;
11
11
import { WordDistance } from 'vs/editor/contrib/suggest/browser/wordDistance' ;
12
12
13
- 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 {
13
+ 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 {
14
14
const suggestion : languages . CompletionItem = {
15
15
label,
16
16
sortText,
17
17
filterText,
18
18
range : { startLineNumber : position . lineNumber , startColumn : position . column - overwriteBefore , endLineNumber : position . lineNumber , endColumn : position . column } ,
19
- insertText : label ,
19
+ insertText : typeof label === 'string' ? label : label . label ,
20
20
kind
21
21
} ;
22
22
const container : languages . CompletionList = {
@@ -275,6 +275,17 @@ suite('CompletionModel', function () {
275
275
assert . strictEqual ( second . completion . label , '<- groups' ) ;
276
276
} ) ;
277
277
278
+ test ( 'Completion item sorting broken when using label details #153026' , function ( ) {
279
+ const itemZZZ = createSuggestItem ( { label : 'ZZZ' } , 0 , languages . CompletionItemKind . Operator , false ) ;
280
+ const itemAAA = createSuggestItem ( { label : 'AAA' } , 0 , languages . CompletionItemKind . Operator , false ) ;
281
+ const itemIII = createSuggestItem ( 'III' , 0 , languages . CompletionItemKind . Operator , false ) ;
282
+
283
+ const cmp = getSuggestionComparator ( SnippetSortOrder . Inline ) ;
284
+ const actual = [ itemZZZ , itemAAA , itemIII ] . sort ( cmp ) ;
285
+
286
+ assert . deepStrictEqual ( actual , [ itemAAA , itemIII , itemZZZ ] ) ;
287
+ } ) ;
288
+
278
289
test ( 'Score only filtered items when typing more, score all when typing less' , function ( ) {
279
290
model = new CompletionModel ( [
280
291
createSuggestItem ( 'console' , 0 ) ,
0 commit comments