Skip to content

Commit 8ebf319

Browse files
Copilotsnehara99
andcommitted
Fix incorrect escaping of semicolons in cmake.configureSettings
Co-authored-by: snehara99 <113148726+snehara99@users.noreply.github.com>
1 parent 98ef3a9 commit 8ebf319

3 files changed

Lines changed: 41 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Features:
77

88
Bug Fixes:
99

10+
- Fix incorrect escaping of semicolons in cmake.configureSettings. [#4682](https://github.com/microsoft/vscode-cmake-tools/issues/4682)
1011
- Fix user-level tasks defined in `~/.config/Code/User/tasks.json` causing infinite spinner. [#4659](https://github.com/microsoft/vscode-cmake-tools/pull/4659)
1112
- Fix "Copy Value" in CMake debugger copying variable name instead of value. [#4551](https://github.com/microsoft/vscode-cmake-tools/issues/4551)
1213
- cmakeDriver: Fixes getCompilerVersion by using compilerPath instead of compilerName. [#4647](https://github.com/microsoft/vscode-cmake-tools/pull/4647) [@lygstate](https://github.com/lygstate)

src/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ export function cmakeify(value: (string | boolean | number | string[] | CMakeVal
303303
ret.value = value ? 'TRUE' : 'FALSE';
304304
} else if (isString(value)) {
305305
ret.type = 'STRING';
306-
ret.value = replaceAll(value, ';', '\\;');
306+
ret.value = value;
307307
} else if (typeof value === 'number') {
308308
ret.type = 'STRING';
309309
ret.value = value.toString();

test/unit-tests/util.test.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,42 @@ suite('Utils test', () => {
2929
}
3030
});
3131
});
32+
33+
suite('cmakeify test', () => {
34+
test('Convert boolean true to CMake BOOL', () => {
35+
const result = util.cmakeify(true);
36+
expect(result.type).to.eq('BOOL');
37+
expect(result.value).to.eq('TRUE');
38+
});
39+
test('Convert boolean false to CMake BOOL', () => {
40+
const result = util.cmakeify(false);
41+
expect(result.type).to.eq('BOOL');
42+
expect(result.value).to.eq('FALSE');
43+
});
44+
test('Convert string to CMake STRING', () => {
45+
const result = util.cmakeify('hello');
46+
expect(result.type).to.eq('STRING');
47+
expect(result.value).to.eq('hello');
48+
});
49+
test('Convert string with semicolons without escaping', () => {
50+
const result = util.cmakeify('libc;compiler-rt');
51+
expect(result.type).to.eq('STRING');
52+
expect(result.value).to.eq('libc;compiler-rt');
53+
});
54+
test('Convert number to CMake STRING', () => {
55+
const result = util.cmakeify(42);
56+
expect(result.type).to.eq('STRING');
57+
expect(result.value).to.eq('42');
58+
});
59+
test('Convert array to CMake STRING with semicolon separator', () => {
60+
const result = util.cmakeify(['a', 'b', 'c']);
61+
expect(result.type).to.eq('STRING');
62+
expect(result.value).to.eq('a;b;c');
63+
});
64+
test('Convert CMakeValue passthrough', () => {
65+
const input: util.CMakeValue = { type: 'FILEPATH', value: '/path/to/file' };
66+
const result = util.cmakeify(input);
67+
expect(result.type).to.eq('FILEPATH');
68+
expect(result.value).to.eq('/path/to/file');
69+
});
70+
});

0 commit comments

Comments
 (0)