Skip to content

Commit 007d692

Browse files
committed
1 parent 80fad3e commit 007d692

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

src/vs/workbench/parts/snippets/electron-browser/snippetsService.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,16 +337,19 @@ export class SnippetSuggestProvider implements ISuggestSupport {
337337
}
338338

339339
// dismbiguate suggestions with same labels
340-
let lastItem: SnippetSuggestion;
341-
for (const item of suggestions.sort(SnippetSuggestion.compareByLabel)) {
342-
if (lastItem && lastItem.label === item.label) {
343-
// use the disambiguateLabel instead of the actual label
344-
lastItem.label = localize('snippetSuggest.longLabel', "{0}, {1}", lastItem.label, lastItem.snippet.name);
345-
item.label = localize('snippetSuggest.longLabel', "{0}, {1}", item.label, item.snippet.name);
340+
suggestions.sort(SnippetSuggestion.compareByLabel);
341+
342+
for (let i = 0; i < suggestions.length; i++) {
343+
let item = suggestions[i];
344+
let to = i + 1;
345+
for (; to < suggestions.length && item.label === suggestions[to].label; to++) {
346+
suggestions[to].label = localize('snippetSuggest.longLabel', "{0}, {1}", suggestions[to].label, suggestions[to].snippet.name);
347+
}
348+
if (to > i + 1) {
349+
suggestions[i].label = localize('snippetSuggest.longLabel', "{0}, {1}", suggestions[i].label, suggestions[i].snippet.name);
350+
i = to;
346351
}
347-
lastItem = item;
348352
}
349-
350353
return { suggestions };
351354
});
352355
}

0 commit comments

Comments
 (0)