Skip to content

Commit

Permalink
Allow single line comment after { for auto indent
Browse files Browse the repository at this point in the history
Fixes #86176
  • Loading branch information
mjbvz committed Feb 27, 2021
1 parent 5766526 commit d89e2e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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|[ ])*[ ]\*([ ]([^\*]|\*(?!\/))*)?$/
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`));
});
});
});

0 comments on commit d89e2e1

Please sign in to comment.