Skip to content

Commit d3e06ee

Browse files
authored
fix: set the correct fallback for Snippet completion (#148)
Co-authored-by: ayame113 <[email protected]>
1 parent 08dd974 commit d3e06ee

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/adapters/autocomplete-adapter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ export default class AutocompleteAdapter {
492492
*/
493493
public static applySnippetToSuggestion(item: CompletionItem, suggestion: SnippetSuggestion): void {
494494
if (item.insertTextFormat === InsertTextFormat.Snippet) {
495-
suggestion.snippet = item.textEdit != null ? item.textEdit.newText : item.insertText || ""
495+
suggestion.snippet = item.textEdit != null ? item.textEdit.newText : item.insertText || item.label
496496
}
497497
}
498498

test/adapters/autocomplete-adapter.test.ts

+8
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ describe("AutoCompleteAdapter", () => {
248248
value: "documentation",
249249
},
250250
},
251+
{
252+
label: "sorawo",
253+
sortText: "f",
254+
insertTextFormat: ls.InsertTextFormat.Snippet,
255+
},
251256
]
252257

253258
beforeEach(() => {
@@ -284,6 +289,9 @@ describe("AutoCompleteAdapter", () => {
284289
expect(results[4].description).is.undefined
285290
expect(results[4].descriptionMarkdown).equals("documentation")
286291
expect(results[4].rightLabel).equals("details")
292+
293+
expect(results[5].displayText).equals("sorawo")
294+
expect((results[5] as SnippetSuggestion).snippet).equals("sorawo")
287295
})
288296

289297
it("respects onDidConvertCompletionItem", async () => {

0 commit comments

Comments
 (0)