From a8b2e1edccb2e6ba5ec2c0bd1124841f9fb39e37 Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Mon, 12 May 2025 06:22:27 -0700 Subject: [PATCH] config: fix nested config resolution strings not getting resolved sometimes See https://github.com/microsoft/vscode/issues/245798#issuecomment-2871753176 Fixes #245798 --- .../common/configurationResolverExpression.ts | 2 +- .../configurationResolverService.test.ts | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/services/configurationResolver/common/configurationResolverExpression.ts b/src/vs/workbench/services/configurationResolver/common/configurationResolverExpression.ts index 1cabb263d78..7a8eb7a34e3 100644 --- a/src/vs/workbench/services/configurationResolver/common/configurationResolverExpression.ts +++ b/src/vs/workbench/services/configurationResolver/common/configurationResolverExpression.ts @@ -283,8 +283,8 @@ export class ConfigurationResolverExpression implements IConfigurationResolve object[newKey] = value; this.parseString(object, newKey, data.value, true, path); } else { - this.parseString(object, propertyName, data.value, false, path); object[propertyName] = object[propertyName].replaceAll(replacement.id, data.value); + this.parseString(object, propertyName, data.value, false, path); } path.pop(); diff --git a/src/vs/workbench/services/configurationResolver/test/electron-sandbox/configurationResolverService.test.ts b/src/vs/workbench/services/configurationResolver/test/electron-sandbox/configurationResolverService.test.ts index 68d24b67cf9..024f956a0d2 100644 --- a/src/vs/workbench/services/configurationResolver/test/electron-sandbox/configurationResolverService.test.ts +++ b/src/vs/workbench/services/configurationResolver/test/electron-sandbox/configurationResolverService.test.ts @@ -1010,4 +1010,32 @@ suite('ConfigurationResolverExpression', () => { 'key that is username: testuser': 'cool!' }); }); + + test('resolves nested values 2 (#245798)', () => { + const expr = ConfigurationResolverExpression.parse({ + env: { + SITE: "${input:site}", + TLD: "${input:tld}", + HOST: "${input:host}", + }, + }); + + for (const r of expr.unresolved()) { + if (r.arg === 'site') { + expr.resolve(r, 'example'); + } else if (r.arg === 'tld') { + expr.resolve(r, 'com'); + } else if (r.arg === 'host') { + expr.resolve(r, 'local.${input:site}.${input:tld}'); + } + } + + assert.deepStrictEqual(expr.toObject(), { + env: { + SITE: 'example', + TLD: 'com', + HOST: 'local.example.com' + } + }); + }); });