Configurations ${WorkSpace} autocomplete broken after update (#155713)

Configurations ${WorkSpace} autocomplete broken after update. Fixes #155638
This commit is contained in:
Martin Aeschlimann 2022-07-20 14:01:52 +02:00 committed by GitHub
parent ce5d92e998
commit 28be5d9906
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 44 additions and 4 deletions

View File

@ -40,8 +40,8 @@ function registerVariableCompletions(pattern: string): vscode.Disposable {
provideCompletionItems(document, position, _token) {
const location = getLocation(document.getText(), document.offsetAt(position));
if (isCompletingInsidePropertyStringValue(document, location, position)) {
let range = document.getWordRangeAtPosition(position, /\$\{[^\}]*\}/);
if (!range || range.end.isEqual(position) || range.start.isEqual(position)) {
let range = document.getWordRangeAtPosition(position, /\$\{[^"\}]*\}?/);
if (!range || range.start.isEqual(position) || range.end.isEqual(position) && document.getText(range).endsWith('}')) {
range = new vscode.Range(position, position);
}

View File

@ -96,8 +96,8 @@ export class SettingsDocument {
return completions;
}
let range = this.document.getWordRangeAtPosition(pos, /\$\{[^\}]*\}/);
if (!range || range.end.isEqual(pos) || range.start.isEqual(pos)) {
let range = this.document.getWordRangeAtPosition(pos, /\$\{[^"\}]*\}?/);
if (!range || range.start.isEqual(pos) || range.end.isEqual(pos) && this.document.getText(range).endsWith('}')) {
range = new vscode.Range(pos, pos);
}

View File

@ -73,6 +73,20 @@ suite('Completions in settings.json', () => {
const expected = { label: '${activeEditorMedium}', resultText };
await testCompletion(testFile, 'jsonc', content, expected);
}
{ // replacing a partial variable
const content = [
'{',
' "window.title": "${a|"',
'}',
].join('\n');
const resultText = [
'{',
' "window.title": "${dirty}"',
'}',
].join('\n');
const expected = { label: '${dirty}', resultText };
await testCompletion(testFile, 'jsonc', content, expected);
}
{ // inserting a literal
const content = [
'{',
@ -382,6 +396,32 @@ suite('Completions in launch.json', () => {
const expected = { label: '${cwd}', resultText };
await testCompletion(testFile, 'jsonc', content, expected);
}
{
const content = [
'{',
' "version": "0.2.0",',
' "configurations": [',
' {',
' "name": "Do It",',
' "program": "${workspace|"',
' }',
' ]',
'}',
].join('\n');
const resultText = [
'{',
' "version": "0.2.0",',
' "configurations": [',
' {',
' "name": "Do It",',
' "program": "${cwd}"',
' }',
' ]',
'}',
].join('\n');
const expected = { label: '${cwd}', resultText };
await testCompletion(testFile, 'jsonc', content, expected);
}
});
});