diff --git a/src/vs/workbench/api/common/extHostTypes.ts b/src/vs/workbench/api/common/extHostTypes.ts index c85ef6a7bba..1497c19da9c 100644 --- a/src/vs/workbench/api/common/extHostTypes.ts +++ b/src/vs/workbench/api/common/extHostTypes.ts @@ -781,7 +781,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 08e6159df75..e4e13098f36 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|}');