Fix #21114
This commit is contained in:
parent
bc69f8d521
commit
778152c86d
|
@ -158,11 +158,18 @@ export class SettingsDocument {
|
||||||
}
|
}
|
||||||
|
|
||||||
private provideLanguageOverridesCompletionItems(location: Location, position: vscode.Position): vscode.ProviderResult<vscode.CompletionItem[]> {
|
private provideLanguageOverridesCompletionItems(location: Location, position: vscode.Position): vscode.ProviderResult<vscode.CompletionItem[]> {
|
||||||
let range = this.document.getWordRangeAtPosition(position) || new vscode.Range(position, position);
|
|
||||||
const text = this.document.getText(range);
|
|
||||||
|
|
||||||
if (location.path.length === 0) {
|
if (location.path.length === 0) {
|
||||||
|
|
||||||
|
let range = this.document.getWordRangeAtPosition(position, /^\s*\[.*]?/) || new vscode.Range(position, position);
|
||||||
|
let text = this.document.getText(range);
|
||||||
|
if (text && text.trim().startsWith('[')) {
|
||||||
|
range = new vscode.Range(new vscode.Position(range.start.line, range.start.character + text.indexOf('[')), range.end);
|
||||||
|
return this.provideLanguageCompletionItems(location, range, language => `"[${language}]"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
range = this.document.getWordRangeAtPosition(position) || new vscode.Range(position, position);
|
||||||
|
text = this.document.getText(range);
|
||||||
let snippet = '"[${1:language}]": {\n\t"$0"\n}';
|
let snippet = '"[${1:language}]": {\n\t"$0"\n}';
|
||||||
|
|
||||||
// Suggestion model word matching includes quotes,
|
// Suggestion model word matching includes quotes,
|
||||||
|
@ -184,6 +191,7 @@ export class SettingsDocument {
|
||||||
if (location.path.length === 1 && location.previousNode && typeof location.previousNode.value === 'string' && location.previousNode.value.startsWith('[')) {
|
if (location.path.length === 1 && location.previousNode && typeof location.previousNode.value === 'string' && location.previousNode.value.startsWith('[')) {
|
||||||
// Suggestion model word matching includes closed sqaure bracket and ending quote
|
// Suggestion model word matching includes closed sqaure bracket and ending quote
|
||||||
// Hence include them in the proposal to replace
|
// Hence include them in the proposal to replace
|
||||||
|
let range = this.document.getWordRangeAtPosition(position) || new vscode.Range(position, position);
|
||||||
return this.provideLanguageCompletionItems(location, range, language => `"[${language}]"`);
|
return this.provideLanguageCompletionItems(location, range, language => `"[${language}]"`);
|
||||||
}
|
}
|
||||||
return Promise.resolve([]);
|
return Promise.resolve([]);
|
||||||
|
|
Loading…
Reference in a new issue