Allow single line comment after { for auto indent

Fixes #86176
This commit is contained in:
Matt Bierner 2021-02-26 20:30:02 -08:00
parent 5766526b0b
commit d89e2e17a5
2 changed files with 12 additions and 1 deletions

View file

@ -15,7 +15,7 @@ import * as languageModeIds from '../utils/languageModeIds';
const jsTsLanguageConfiguration: vscode.LanguageConfiguration = {
indentationRules: {
decreaseIndentPattern: /^((?!.*?\/\*).*\*\/)?\s*[\}\]].*$/,
increaseIndentPattern: /^((?!\/\/).)*(\{[^}"'`]*|\([^)"'`]*|\[[^\]"'`]*)$/,
increaseIndentPattern: /^((?!\/\/).)*(\{([^}"'`]*|(\t|[ ])*\/\/.*)|\([^)"'`]*|\[[^\]"'`]*)$/,
// e.g. * ...| or */| or *-----*/|
unIndentedLinePattern: /^(\t|[ ])*[ ]\*[^/]*\*\/\s*$|^(\t|[ ])*[ ]\*\/\s*$|^(\t|[ ])*[ ]\*([ ]([^\*]|\*(?!\/))*)?$/
},

View file

@ -110,4 +110,15 @@ suite.skip('OnEnter', () => {
` * x`));
});
});
test('should indent after if block followed by comment with quote', () => {
return withRandomFileEditor(`if (true) { // '${CURSOR}`, 'js', async (_editor, document) => {
await type(document, '\nx');
assert.strictEqual(
document.getText(),
joinLines(
`if (true) { // '`,
` x`));
});
});
});