未验证 提交 04a7220e 编写于 作者: J Johannes Rieken 提交者: GitHub

Merge pull request #107348 from jeanp413/fix-107220

Fixes SnippetString.appendChoice does not escape commas in choices
......@@ -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;
......
......@@ -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|}');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册