mirror of
https://github.com/Microsoft/vscode
synced 2024-10-02 09:18:59 +00:00
Merge pull request #208291 from microsoft/aiday/addingIndentationForIfForWhile
Indent next line for if/for/while statement followed by whitespace
This commit is contained in:
commit
a00f2e64f4
|
@ -139,7 +139,7 @@
|
|||
"pattern": "^(\\t|[ ])*[ ]\\*[^/]*\\*/\\s*$|^(\\t|[ ])*[ ]\\*/\\s*$|^(\\t|[ ])*\\*([ ]([^\\*]|\\*(?!/))*)?$"
|
||||
},
|
||||
"indentNextLinePattern": {
|
||||
"pattern": "^.*=>\\s*$"
|
||||
"pattern": "^((.*=>\\s*)|((.*[^\\w]+|\\s*)(if|while|for)\\s*\\(.*\\)\\s*))$"
|
||||
}
|
||||
},
|
||||
"onEnterRules": [
|
||||
|
|
|
@ -663,15 +663,13 @@ suite('`Full` Auto Indent On Type - TypeScript/JavaScript', () => {
|
|||
});
|
||||
});
|
||||
|
||||
test.skip('issue #43244: incorrect indentation', () => {
|
||||
test('issue #43244: incorrect indentation after if/for/while without braces', () => {
|
||||
|
||||
// https://github.com/microsoft/vscode/issues/43244
|
||||
// potential regex to fix: "^.*[if|while|for]\s*\(.*\)\s*",
|
||||
|
||||
const model = createTextModel([
|
||||
'function f() {',
|
||||
' if (condition)',
|
||||
' return;',
|
||||
'}'
|
||||
].join('\n'), languageId, {});
|
||||
disposables.add(model);
|
||||
|
@ -679,23 +677,22 @@ suite('`Full` Auto Indent On Type - TypeScript/JavaScript', () => {
|
|||
withTestCodeEditor(model, { autoIndent: "full" }, (editor, viewModel, instantiationService) => {
|
||||
|
||||
registerLanguage(instantiationService, languageId, Language.TypeScript, disposables);
|
||||
editor.setSelection(new Selection(3, 16, 3, 16));
|
||||
editor.setSelection(new Selection(2, 19, 2, 19));
|
||||
viewModel.type("\n", 'keyboard');
|
||||
assert.strictEqual(model.getValue(), [
|
||||
'function f() {',
|
||||
' if (condition)',
|
||||
' return;',
|
||||
'',
|
||||
' ',
|
||||
'}',
|
||||
].join('\n'));
|
||||
|
||||
viewModel.type("return;");
|
||||
viewModel.type("\n", 'keyboard');
|
||||
assert.strictEqual(model.getValue(), [
|
||||
'function f() {',
|
||||
' if (condition)',
|
||||
' return;',
|
||||
'',
|
||||
'',
|
||||
' ',
|
||||
'}',
|
||||
].join('\n'));
|
||||
});
|
||||
|
|
|
@ -8,5 +8,5 @@ export const javascriptIndentationRules = {
|
|||
increaseIndentPattern: /^((?!\/\/).)*(\{([^}"'`]*|(\t|[ ])*\/\/.*)|\([^)"'`]*|\[[^\]"'`]*)$/,
|
||||
// e.g. * ...| or */| or *-----*/|
|
||||
unIndentedLinePattern: /^(\t|[ ])*[ ]\*[^/]*\*\/\s*$|^(\t|[ ])*[ ]\*\/\s*$|^(\t|[ ])*[ ]\*([ ]([^\*]|\*(?!\/))*)?$/,
|
||||
indentNextLinePattern: /^.*=>\s*$/,
|
||||
indentNextLinePattern: /^((.*=>\s*)|((.*[^\w]+|\s*)(if|while|for)\s*\(.*\)\s*))$/,
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue