mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-25 04:36:23 +00:00
fix indentation (#141997)
* fix indentation * add tests * make regex valid
This commit is contained in:
@@ -15,7 +15,7 @@ import * as languageModeIds from '../utils/languageIds';
|
||||
const jsTsLanguageConfiguration: vscode.LanguageConfiguration = {
|
||||
indentationRules: {
|
||||
decreaseIndentPattern: /^((?!.*?\/\*).*\*\/)?\s*[\}\]].*$/,
|
||||
increaseIndentPattern: /^((?!\/\/).)*(\{([^}"'`]*|(\t|[ ])*\/\/.*)|\([^)"'`]*|\[[^\]"'`]*)$/,
|
||||
increaseIndentPattern: /^((?!\/\/).)*(\{([^}"'`/]*|(\t|[ ])*\/\/.*)|\([^)"'`/]*|\[[^\]"'`/]*)$/,
|
||||
// e.g. * ...| or */| or *-----*/|
|
||||
unIndentedLinePattern: /^(\t|[ ])*[ ]\*[^/]*\*\/\s*$|^(\t|[ ])*[ ]\*\/\s*$|^(\t|[ ])*[ ]\*([ ]([^\*]|\*(?!\/))*)?$/
|
||||
},
|
||||
|
||||
@@ -168,4 +168,22 @@ suite('OnEnter', () => {
|
||||
testIndentAction('', ' * test() {', '', IndentAction.Indent, null, 0);
|
||||
testIndentAction(' ', ' * test() {', '', IndentAction.Indent, null, 0);
|
||||
});
|
||||
|
||||
test('issue #141816', () => {
|
||||
let support = new OnEnterSupport({
|
||||
onEnterRules: javascriptOnEnterRules
|
||||
});
|
||||
let testIndentAction = (beforeText: string, afterText: string, expected: IndentAction) => {
|
||||
let actual = support.onEnter(EditorAutoIndentStrategy.Advanced, '', beforeText, afterText);
|
||||
if (expected === IndentAction.None) {
|
||||
assert.strictEqual(actual, null);
|
||||
} else {
|
||||
assert.strictEqual(actual!.indentAction, expected);
|
||||
}
|
||||
};
|
||||
|
||||
testIndentAction('const r = /{/;', '', IndentAction.None);
|
||||
testIndentAction('const r = /{[0-9]/;', '', IndentAction.None);
|
||||
testIndentAction('const r = /[a-zA-Z]{/;', '', IndentAction.None);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user