From d9e2b651c4893ad5ecfb931bc950ca61e2505a7d Mon Sep 17 00:00:00 2001 From: kwy404 Date: Thu, 1 Oct 2026 19:25:02 -0300 Subject: [PATCH 1/2] fix auto indentation after a key with an anchor The increaseIndentPattern in language-configuration.json contained the HTML entity & instead of &, so lines such as 'base: &base' never matched. Signed-off-by: kwy404 --- language-configuration.json | 2 +- test/languageConfiguration.test.ts | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test/languageConfiguration.test.ts diff --git a/language-configuration.json b/language-configuration.json index b8e9fac1..7caa1d21 100644 --- a/language-configuration.json +++ b/language-configuration.json @@ -31,7 +31,7 @@ } }, "indentationRules": { - "increaseIndentPattern": "^\\s*.*(:|-) ?(&\\w+)?(\\{[^}\"']*|\\([^)\"']*)?$", + "increaseIndentPattern": "^\\s*.*(:|-) ?(&\\w+)?(\\{[^}\"']*|\\([^)\"']*)?$", "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..ddb92037 --- /dev/null +++ b/test/languageConfiguration.test.ts @@ -0,0 +1,18 @@ +/*--------------------------------------------------------------------------------------------- + * 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')); + }); +}); From bd2355983e64de63fc787e1371a8983e6fc41210 Mon Sep 17 00:00:00 2001 From: kwy404 Date: Fri, 2 Oct 2026 17:12:08 -0300 Subject: [PATCH 2/2] Allow any anchor name characters in increaseIndentPattern --- language-configuration.json | 2 +- test/languageConfiguration.test.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/language-configuration.json b/language-configuration.json index 7caa1d21..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 index ddb92037..2f30cdee 100644 --- a/test/languageConfiguration.test.ts +++ b/test/languageConfiguration.test.ts @@ -14,5 +14,9 @@ describe('Language configuration', () => { 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')); }); });