Skip to content

Commit 04a7220

Browse files
authored
Merge pull request microsoft#107348 from jeanp413/fix-107220
Fixes SnippetString.appendChoice does not escape commas in choices
2 parents d9ba49f + 459543b commit 04a7220

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/vs/workbench/api/common/extHostTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ export class SnippetString {
781781
}
782782

783783
appendChoice(values: string[], number: number = this._tabstop++): SnippetString {
784-
const value = SnippetString._escape(values.toString());
784+
const value = values.map(s => s.replace(/\$|}|\\|,/g, '\\$&')).join(',');
785785

786786
this.value += '${';
787787
this.value += number;

src/vs/workbench/test/browser/api/extHostTypes.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,10 @@ suite('ExtHostTypes', function () {
524524
string.appendChoice(['b', 'a', 'r']);
525525
assert.equal(string.value, '${1|b,a,r|}');
526526

527+
string = new types.SnippetString();
528+
string.appendChoice(['b,1', 'a,2', 'r,3']);
529+
assert.equal(string.value, '${1|b\\,1,a\\,2,r\\,3|}');
530+
527531
string = new types.SnippetString();
528532
string.appendChoice(['b', 'a', 'r'], 0);
529533
assert.equal(string.value, '${0|b,a,r|}');

0 commit comments

Comments
 (0)