diff --git a/src/vs/workbench/api/common/extHostTypes.ts b/src/vs/workbench/api/common/extHostTypes.ts index 43dd6f160577b61cbee63b6a3bf936618109793f..dcaeaa1903657bd4d7fa838ac4b174f0d4b948e7 100644 --- a/src/vs/workbench/api/common/extHostTypes.ts +++ b/src/vs/workbench/api/common/extHostTypes.ts @@ -782,7 +782,7 @@ export class SnippetString { } appendChoice(values: string[], number: number = this._tabstop++): SnippetString { - const value = SnippetString._escape(values.toString()); + const value = values.map(s => s.replace(/\$|}|\\|,/g, '\\$&')).join(','); this.value += '${'; this.value += number; diff --git a/src/vs/workbench/test/browser/api/extHostTypes.test.ts b/src/vs/workbench/test/browser/api/extHostTypes.test.ts index 08e6159df7533510998f71c52e43226cb8af7475..e4e13098f362e16189ea75772b3ddc1a2e709d9f 100644 --- a/src/vs/workbench/test/browser/api/extHostTypes.test.ts +++ b/src/vs/workbench/test/browser/api/extHostTypes.test.ts @@ -524,6 +524,10 @@ suite('ExtHostTypes', function () { string.appendChoice(['b', 'a', 'r']); assert.equal(string.value, '${1|b,a,r|}'); + string = new types.SnippetString(); + string.appendChoice(['b,1', 'a,2', 'r,3']); + assert.equal(string.value, '${1|b\\,1,a\\,2,r\\,3|}'); + string = new types.SnippetString(); string.appendChoice(['b', 'a', 'r'], 0); assert.equal(string.value, '${0|b,a,r|}');