Fix single line if/else and loop indentation
This commit is contained in:
parent
66b1668b66
commit
d021de11ab
|
@ -76,6 +76,15 @@
|
|||
"indent": "none",
|
||||
"removeText": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
// Decrease indentation after single line if/else if/else, for, foreach, or while
|
||||
"previousLineText": "^\\s*(((else ?)?if|for(each)?|while)\\s*\\(.*\\)\\s*|else\\s*)$",
|
||||
// But make sure line doesn't have braces or is not another if statement
|
||||
"beforeText": "^\\s+([^{i\\s]|i(?!f\\b))",
|
||||
"action": {
|
||||
"indent": "outdent"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -49,6 +49,13 @@ const jsTsLanguageConfiguration: vscode.LanguageConfiguration = {
|
|||
beforeText: /^\s*(\bcase\s.+:|\bdefault:)$/,
|
||||
afterText: /^(?!\s*(\bcase\b|\bdefault\b))/,
|
||||
action: { indentAction: vscode.IndentAction.Indent },
|
||||
},
|
||||
{
|
||||
// Decrease indentation after single line if/else if/else, for, or while
|
||||
previousLineText: /^\s*(((else )?if|for|while)\s*\(.*\)\s*|else\s*)$/,
|
||||
// But make sure line doesn't have braces or is not another if statement
|
||||
beforeText: /^\s+([^{i\s]|i(?!f\b))/,
|
||||
action: { indentAction: vscode.IndentAction.Outdent },
|
||||
}
|
||||
]
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue