mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-24 01:11:34 +01:00
Fixes #86386
This commit is contained in:
@@ -126,8 +126,9 @@ export class SnippetCompletionProvider implements CompletionItemProvider {
|
||||
// add remaing snippets when the current prefix ends in whitespace or when no
|
||||
// interesting positions have been found
|
||||
availableSnippets.forEach(snippet => {
|
||||
const range = Range.fromPositions(position);
|
||||
suggestions.push(new SnippetCompletion(snippet, { replace: range, insert: range }));
|
||||
let insert = Range.fromPositions(position);
|
||||
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 () {
|
||||
[first] = result.suggestions;
|
||||
assert.equal((first.range as any).insert.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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user