From 459543baffe3d9b5000f768b6d3eeba1d5812c9b Mon Sep 17 00:00:00 2001 From: jeanp413 Date: Thu, 24 Sep 2020 04:18:17 -0500 Subject: [PATCH] Fixes #107220 --- src/vs/workbench/api/common/extHostTypes.ts | 2 +- src/vs/workbench/test/browser/api/extHostTypes.test.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/api/common/extHostTypes.ts b/src/vs/workbench/api/common/extHostTypes.ts index 43dd6f16057..dcaeaa19036 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 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|}');