mirror of
https://github.com/Microsoft/vscode
synced 2024-10-12 22:37:41 +00:00
Avoid unexpected value changes
This commit is contained in:
parent
6378c89efd
commit
92b36ffc78
|
@ -740,9 +740,15 @@ export class SnippetString {
|
|||
return this;
|
||||
}
|
||||
|
||||
appendChoice(values: string[], number?: number): SnippetString {
|
||||
this.appendPlaceholder(values.toString(), number);
|
||||
this.value = this.value.replace(/:/g, '|').replace(/}/g, '|}');
|
||||
appendChoice(values: string[], number: number = this._tabstop++): SnippetString {
|
||||
const value = SnippetString._escape(values.toString());
|
||||
|
||||
this.value += '${';
|
||||
this.value += number;
|
||||
this.value += '|';
|
||||
this.value += value;
|
||||
this.value += '|}';
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -534,6 +534,18 @@ suite('ExtHostTypes', function () {
|
|||
string = new types.SnippetString();
|
||||
string.appendChoice(['b', 'a', 'r'], 0);
|
||||
assert.equal(string.value, '${0|b,a,r|}');
|
||||
|
||||
string = new types.SnippetString();
|
||||
string.appendText('foo').appendChoice(['far', 'boo']).appendText('bar');
|
||||
assert.equal(string.value, 'foo${1|far,boo|}bar');
|
||||
|
||||
string = new types.SnippetString();
|
||||
string.appendText('foo').appendChoice(['far', '$boo']).appendText('bar');
|
||||
assert.equal(string.value, 'foo${1|far,\\$boo|}bar');
|
||||
|
||||
string = new types.SnippetString();
|
||||
string.appendText('foo').appendPlaceholder('farboo').appendChoice(['far', 'boo']).appendText('bar');
|
||||
assert.equal(string.value, 'foo${1:farboo}${2|far,boo|}bar');
|
||||
});
|
||||
|
||||
test('instanceof doesn\'t work for FileSystemError #49386', function () {
|
||||
|
|
Loading…
Reference in a new issue