Fixes 114236: Add a multi-line comment regex to unIndentedLinePattern (#114478)

* Add a multi-line comment regex to unIndentedLinePattern

* Add multi-line comment block indentation tests

* Fix a multi-line comment block indentation test
This commit is contained in:
Shunsuke Iwamoto 2021-02-10 10:05:21 +09:00 committed by GitHub
parent b2724146f0
commit 76524ef589
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 1 deletions

View file

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

View file

@ -67,4 +67,47 @@ suite.skip('OnEnter', () => {
` x`));
});
});
test('should not indent after a multi-line comment block 1', () => {
return withRandomFileEditor(`/*-----\n * line 1\n * line 2\n *-----*/\n${CURSOR}`, 'js', async (_editor, document) => {
await type(document, '\nx');
assert.strictEqual(
document.getText(),
joinLines(
`/*-----`,
` * line 1`,
` * line 2`,
` *-----*/`,
``,
`x`));
});
});
test('should not indent after a multi-line comment block 2', () => {
return withRandomFileEditor(`/*-----\n * line 1\n * line 2\n */\n${CURSOR}`, 'js', async (_editor, document) => {
await type(document, '\nx');
assert.strictEqual(
document.getText(),
joinLines(
`/*-----`,
` * line 1`,
` * line 2`,
` */`,
``,
`x`));
});
});
test('should indent within a multi-line comment block', () => {
return withRandomFileEditor(`/*-----\n * line 1\n * line 2${CURSOR}`, 'js', async (_editor, document) => {
await type(document, '\nx');
assert.strictEqual(
document.getText(),
joinLines(
`/*-----`,
` * line 1`,
` * line 2`,
` * x`));
});
});
});