提交 fe37ea75 编写于 作者: J jeanp413

Fixes #86386

上级 a416c77e
...@@ -126,8 +126,9 @@ export class SnippetCompletionProvider implements CompletionItemProvider { ...@@ -126,8 +126,9 @@ export class SnippetCompletionProvider implements CompletionItemProvider {
// add remaing snippets when the current prefix ends in whitespace or when no // add remaing snippets when the current prefix ends in whitespace or when no
// interesting positions have been found // interesting positions have been found
availableSnippets.forEach(snippet => { availableSnippets.forEach(snippet => {
const range = Range.fromPositions(position); let insert = Range.fromPositions(position);
suggestions.push(new SnippetCompletion(snippet, { replace: range, insert: range })); let replace = startsWith(lineSuffixLow, snippet.prefixLow) ? insert.setEndPosition(position.lineNumber, position.column + snippet.prefixLow.length) : insert;
suggestions.push(new SnippetCompletion(snippet, { replace, insert }));
}); });
} }
......
...@@ -438,5 +438,13 @@ suite('SnippetsService', function () { ...@@ -438,5 +438,13 @@ suite('SnippetsService', function () {
[first] = result.suggestions; [first] = result.suggestions;
assert.equal((first.range as any).insert.endColumn, 3); assert.equal((first.range as any).insert.endColumn, 3);
assert.equal((first.range as any).replace.endColumn, 3); assert.equal((first.range as any).replace.endColumn, 3);
model = TextModel.createFromString('not word', undefined, modeService.getLanguageIdentifier('fooLang'));
result = await provider.provideCompletionItems(model, new Position(1, 1), context)!;
assert.equal(result.suggestions.length, 1);
[first] = result.suggestions;
assert.equal((first.range as any).insert.endColumn, 1);
assert.equal((first.range as any).replace.endColumn, 9);
}); });
}); });
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册