Merge pull request #208319 from microsoft/local-quail

Indent on enter from within [], {}, ()
This commit is contained in:
Aiday Marlen Kyzy 2024-03-22 11:07:23 +01:00 committed by GitHub
commit b0725d3bf2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 47 additions and 2 deletions

View File

@ -218,6 +218,33 @@
"action": {
"indent": "outdent"
}
}
},
// Indent when pressing enter from inside ()
{
"beforeText": "^.*\\([^\\)]*$",
"afterText": "^\\s*\\).*$",
"action": {
"indent": "indentOutdent",
"appendText": "\t",
}
},
// Indent when pressing enter from inside {}
{
"beforeText": "^.*\\{[^\\}]*$",
"afterText": "^\\s*\\}.*$",
"action": {
"indent": "indentOutdent",
"appendText": "\t",
}
},
// Indent when pressing enter from inside []
{
"beforeText": "^.*\\[[^\\]]*$",
"afterText": "^\\s*\\].*$",
"action": {
"indent": "indentOutdent",
"appendText": "\t",
}
},
]
}

View File

@ -874,7 +874,7 @@ suite('`Full` Auto Indent On Type - TypeScript/JavaScript', () => {
});
});
test.skip('issue #43244: indent when lambda arrow function is detected, outdent when end is reached', () => {
test('issue #43244: indent when lambda arrow function is detected, outdent when end is reached', () => {
// https://github.com/microsoft/vscode/issues/43244

View File

@ -40,4 +40,22 @@ export const javascriptOnEnterRules = [
beforeText: /^\s+([^{i\s]|i(?!f\b))/,
action: { indentAction: IndentAction.Outdent }
},
// Indent when pressing enter from inside ()
{
beforeText: /^.*\([^\)]*$/,
afterText: /^\s*\).*$/,
action: { indentAction: IndentAction.IndentOutdent, appendText: '\t' }
},
// Indent when pressing enter from inside {}
{
beforeText: /^.*\{[^\}]*$/,
afterText: /^\s*\}.*$/,
action: { indentAction: IndentAction.IndentOutdent, appendText: '\t' }
},
// Indent when pressing enter from inside []
{
beforeText: /^.*\[[^\]]*$/,
afterText: /^\s*\].*$/,
action: { indentAction: IndentAction.IndentOutdent, appendText: '\t' }
},
];