Johannes Rieken 2021-02-25 10:43:13 +01:00
parent b85eb124d8
commit 9efc326b9b

View file

@ -180,7 +180,21 @@ function registerContextKeyCompletions(): vscode.Disposable {
return;
}
const replacing = document.getWordRangeAtPosition(position, /[^"\s]+/);
// for JSON everything with quotes is a word
const jsonWord = document.getWordRangeAtPosition(position);
if (!jsonWord || jsonWord.start.isEqual(position) || jsonWord.end.isEqual(position)) {
// we aren't inside a "JSON word" or on its quotes
return;
}
let replacing: vscode.Range | undefined;
if (jsonWord.end.character - jsonWord.start.character === 2 || document.getWordRangeAtPosition(position, /\s+/)) {
// empty json word or on whitespace
replacing = new vscode.Range(position, position);
} else {
replacing = document.getWordRangeAtPosition(position, /[a-zA-Z.]+/);
}
if (!replacing) {
return;
}