mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-02 22:41:31 +01:00
json: use default word pattern (#151754)
This commit is contained in:
committed by
GitHub
parent
53130238b4
commit
375681e51e
@@ -24,7 +24,7 @@ export class PackageDocument {
|
||||
}
|
||||
|
||||
private provideLanguageOverridesCompletionItems(location: Location, position: vscode.Position): vscode.ProviderResult<vscode.CompletionItem[]> {
|
||||
let range = this.document.getWordRangeAtPosition(position) || new vscode.Range(position, position);
|
||||
let range = this.getReplaceRange(location, position);
|
||||
const text = this.document.getText(range);
|
||||
|
||||
if (location.path.length === 2) {
|
||||
@@ -65,6 +65,17 @@ export class PackageDocument {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
private getReplaceRange(location: Location, position: vscode.Position) {
|
||||
const node = location.previousNode;
|
||||
if (node) {
|
||||
const nodeStart = this.document.positionAt(node.offset), nodeEnd = this.document.positionAt(node.offset + node.length);
|
||||
if (nodeStart.isBeforeOrEqual(position) && nodeEnd.isAfterOrEqual(position)) {
|
||||
return new vscode.Range(nodeStart, nodeEnd);
|
||||
}
|
||||
}
|
||||
return new vscode.Range(position, position);
|
||||
}
|
||||
|
||||
private newSimpleCompletionItem(text: string, range: vscode.Range, description?: string, insertText?: string): vscode.CompletionItem {
|
||||
const item = new vscode.CompletionItem(text);
|
||||
item.kind = vscode.CompletionItemKind.Value;
|
||||
|
||||
Reference in New Issue
Block a user