mirror of
https://github.com/Microsoft/vscode
synced 2024-11-05 18:29:38 +00:00
Merge pull request #147422 from amanasifkhalid/snippet-transform-case
This commit is contained in:
commit
a8f5fc20e0
2 changed files with 9 additions and 6 deletions
|
@ -395,8 +395,7 @@ export class FormatString extends Marker {
|
|||
return value;
|
||||
}
|
||||
return match.map(word => {
|
||||
return word.charAt(0).toUpperCase()
|
||||
+ word.substr(1).toLowerCase();
|
||||
return word.charAt(0).toUpperCase() + word.substr(1);
|
||||
})
|
||||
.join('');
|
||||
}
|
||||
|
@ -408,11 +407,9 @@ export class FormatString extends Marker {
|
|||
}
|
||||
return match.map((word, index) => {
|
||||
if (index === 0) {
|
||||
return word.toLowerCase();
|
||||
} else {
|
||||
return word.charAt(0).toUpperCase()
|
||||
+ word.substr(1).toLowerCase();
|
||||
return word.charAt(0).toLowerCase() + word.substr(1);
|
||||
}
|
||||
return word.charAt(0).toUpperCase() + word.substr(1);
|
||||
})
|
||||
.join('');
|
||||
}
|
||||
|
|
|
@ -656,8 +656,14 @@ suite('SnippetParser', () => {
|
|||
assert.strictEqual(new FormatString(1, 'capitalize').resolve('bar no repeat'), 'Bar no repeat');
|
||||
assert.strictEqual(new FormatString(1, 'pascalcase').resolve('bar-foo'), 'BarFoo');
|
||||
assert.strictEqual(new FormatString(1, 'pascalcase').resolve('bar-42-foo'), 'Bar42Foo');
|
||||
assert.strictEqual(new FormatString(1, 'pascalcase').resolve('snake_AndPascalCase'), 'SnakeAndPascalCase');
|
||||
assert.strictEqual(new FormatString(1, 'pascalcase').resolve('kebab-AndPascalCase'), 'KebabAndPascalCase');
|
||||
assert.strictEqual(new FormatString(1, 'pascalcase').resolve('_justPascalCase'), 'JustPascalCase');
|
||||
assert.strictEqual(new FormatString(1, 'camelcase').resolve('bar-foo'), 'barFoo');
|
||||
assert.strictEqual(new FormatString(1, 'camelcase').resolve('bar-42-foo'), 'bar42Foo');
|
||||
assert.strictEqual(new FormatString(1, 'camelcase').resolve('snake_AndCamelCase'), 'snakeAndCamelCase');
|
||||
assert.strictEqual(new FormatString(1, 'camelcase').resolve('kebab-AndCamelCase'), 'kebabAndCamelCase');
|
||||
assert.strictEqual(new FormatString(1, 'camelcase').resolve('_JustCamelCase'), 'justCamelCase');
|
||||
assert.strictEqual(new FormatString(1, 'notKnown').resolve('input'), 'input');
|
||||
|
||||
// if
|
||||
|
|
Loading…
Reference in a new issue