yaml: fix the anchor group in increaseIndentPattern
The pattern had an HTML-escaped "&" where it meant "&", so a key followed by an anchor (foo: &anchor) never increased the indent.
This commit is contained in:
1 parent
da856c50ae
commit
6d1a2764c0
2 files changed
+44
-2
No files matched your search
@@ -29,7 +29,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"indentationRules": {
|
"indentationRules": {
|
||||||
"increaseIndentPattern": "^\\s*.*(:|-) ?(&\\w+)?(\\{[^}\"']*|\\([^)\"']*)?$",
|
"increaseIndentPattern": "^\\s*.*(:|-) ?(&\\w+)?(\\{[^}\"']*|\\([^)\"']*)?$",
|
||||||
"decreaseIndentPattern": "^\\s+\\}$"
|
"decreaseIndentPattern": "^\\s+\\}$"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -35,7 +35,8 @@ function getIRange(range: IRange): IRange {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const enum LanguageId {
|
const enum LanguageId {
|
||||||
TypeScript = 'ts-test'
|
TypeScript = 'ts-test',
|
||||||
|
Yaml = 'yaml-test'
|
||||||
}
|
}
|
||||||
|
|
||||||
function forceTokenizationFromLineToLine(model: ITextModel, startLine: number, endLine: number): void {
|
function forceTokenizationFromLineToLine(model: ITextModel, startLine: number, endLine: number): void {
|
||||||
@@ -59,6 +60,9 @@ function registerLanguageConfiguration(instantiationService: TestInstantiationSe
|
|||||||
case LanguageId.TypeScript:
|
case LanguageId.TypeScript:
|
||||||
configPath = FileAccess.asFileUri('vs/workbench/contrib/codeEditor/test/node/language-configuration.json').fsPath;
|
configPath = FileAccess.asFileUri('vs/workbench/contrib/codeEditor/test/node/language-configuration.json').fsPath;
|
||||||
break;
|
break;
|
||||||
|
case LanguageId.Yaml:
|
||||||
|
configPath = join(FileAccess.asFileUri('').fsPath, '..', 'extensions', 'yaml', 'language-configuration.json');
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error('Unknown languageId');
|
throw new Error('Unknown languageId');
|
||||||
}
|
}
|
||||||
@@ -548,3 +552,41 @@ suite('Auto-Reindentation - TypeScript/JavaScript', () => {
|
|||||||
assert.deepStrictEqual(editOperations.length, 0);
|
assert.deepStrictEqual(editOperations.length, 0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
suite('Auto-Reindentation - YAML', () => {
|
||||||
|
|
||||||
|
const languageId = LanguageId.Yaml;
|
||||||
|
const options: IRelaxedTextModelCreationOptions = { tabSize: 2, indentSize: 2, insertSpaces: true };
|
||||||
|
let disposables: DisposableStore;
|
||||||
|
let instantiationService: TestInstantiationService;
|
||||||
|
let languageConfigurationService: ILanguageConfigurationService;
|
||||||
|
|
||||||
|
setup(() => {
|
||||||
|
disposables = new DisposableStore();
|
||||||
|
instantiationService = createModelServices(disposables);
|
||||||
|
languageConfigurationService = instantiationService.get(ILanguageConfigurationService);
|
||||||
|
disposables.add(instantiationService);
|
||||||
|
disposables.add(registerLanguage(instantiationService, languageId));
|
||||||
|
});
|
||||||
|
|
||||||
|
teardown(() => {
|
||||||
|
disposables.dispose();
|
||||||
|
});
|
||||||
|
|
||||||
|
ensureNoDisposablesAreLeakedInTestSuite();
|
||||||
|
|
||||||
|
test('Issue #330394: indent after a key with an anchor', () => {
|
||||||
|
// issue: https://github.com/microsoft/vscode/issues/330394
|
||||||
|
|
||||||
|
const fileContents = [
|
||||||
|
'foo: &anchor',
|
||||||
|
'bar: 1',
|
||||||
|
].join('\n');
|
||||||
|
const model = disposables.add(instantiateTextModel(instantiationService, fileContents, languageId, options));
|
||||||
|
const editOperations = getReindentEditOperations(model, languageConfigurationService, 1, model.getLineCount());
|
||||||
|
assert.deepStrictEqual(editOperations.map(operation => ({ range: getIRange(operation.range), text: operation.text })), [{
|
||||||
|
range: { startLineNumber: 2, startColumn: 1, endLineNumber: 2, endColumn: 1 },
|
||||||
|
text: ' '
|
||||||
|
}]);
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in new issue
Block a user