diff --git a/language-configuration.json b/language-configuration.json index b8e9fac1..c8af8bf2 100644 --- a/language-configuration.json +++ b/language-configuration.json @@ -31,7 +31,7 @@ } }, "indentationRules": { - "increaseIndentPattern": "^\\s*.*(:|-) ?(&\\w+)?(\\{[^}\"']*|\\([^)\"']*)?$", + "increaseIndentPattern": "^\\s*.*(:|-) ?(&[^\\s,\\[\\]{}]+)?(\\{[^}\"']*|\\([^)\"']*)?$", "decreaseIndentPattern": "^\\s+\\}$" }, "wordPattern": "(^.?[^\\s]+)+|([^\\s\n={[][\\w\\-\\.\/$%&*:\"']+)" diff --git a/test/languageConfiguration.test.ts b/test/languageConfiguration.test.ts new file mode 100644 index 00000000..2f30cdee --- /dev/null +++ b/test/languageConfiguration.test.ts @@ -0,0 +1,22 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Red Hat, Inc. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import * as assert from 'assert'; +import * as fs from 'fs'; +import * as path from 'path'; + +describe('Language configuration', () => { + it('increases indentation after a key or list item with an anchor', () => { + const configPath = path.resolve(__dirname, '..', '..', 'language-configuration.json'); + const config = JSON.parse(fs.readFileSync(configPath, 'utf8')); + const increaseIndentPattern = new RegExp(config.indentationRules.increaseIndentPattern); + assert.ok(increaseIndentPattern.test('base: &base')); + assert.ok(increaseIndentPattern.test('- &item')); + assert.ok(increaseIndentPattern.test('second: &ref-erance')); + assert.ok(increaseIndentPattern.test('- &item.v2')); + assert.ok(!increaseIndentPattern.test('key: value')); + assert.ok(!increaseIndentPattern.test('- item')); + }); +});