arrow function

This commit is contained in:
Aiday Marlen Kyzy 2024-03-20 17:41:07 +01:00
parent b329f9c2a5
commit 5cc65d29ab
No known key found for this signature in database
GPG key ID: 24A8B53DBD26FF4E
3 changed files with 32 additions and 5 deletions

View file

@ -215,6 +215,12 @@
"action": {
"indent": "outdent"
}
}
},
{
"beforeText": "^\\s*(var|const|let)\\s+\\w+\\s*=\\s*\\(.*\\)\\s*=>\\s*$",
"action": {
"indent": "indent"
}
},
]
}

View file

@ -545,9 +545,9 @@ suite('`Full` Auto Indent On Type - TypeScript/JavaScript', () => {
// Failing tests from issues...
test.skip('issue #116843: indent after arrow function', () => {
test('issue #208215: indent after arrow function', () => {
// https://github.com/microsoft/vscode/issues/116843
// https://github.com/microsoft/vscode/issues/208215
const model = createTextModel("", languageId, {});
disposables.add(model);
@ -562,11 +562,28 @@ suite('`Full` Auto Indent On Type - TypeScript/JavaScript', () => {
'const add1 = (n) =>',
' ',
].join('\n'));
viewModel.type('n + 1;');
});
});
test.skip('issue #116843: indent after arrow function', () => {
// https://github.com/microsoft/vscode/issues/116843
const model = createTextModel("", languageId, {});
disposables.add(model);
withTestCodeEditor(model, { autoIndent: "full" }, (editor, viewModel, instantiationService) => {
registerLanguage(instantiationService, languageId, Language.TypeScript, disposables);
viewModel.type([
'const add1 = (n) =>',
' n + 1;',
].join('\n'));
viewModel.type("\n", 'keyboard');
assert.strictEqual(model.getValue(), [
'const add1 = (n) =>',
' n + 1;',
' n + 1;',
'',
].join('\n'));
});

View file

@ -40,4 +40,8 @@ export const javascriptOnEnterRules = [
beforeText: /^\s+([^{i\s]|i(?!f\b))/,
action: { indentAction: IndentAction.Outdent }
},
{
beforeText: /^\s*(var|const|let)\s+\w+\s*=\s*\(.*\)\s*=>\s*$/,
action: { indentAction: IndentAction.Indent }
},
];