Skip to content

Commit 7b9e11a

Browse files
committed
Make arrow-functions one-liners
Summary: This fixes the indentation for expression arrow functions that are continued on multiple lines. This does not affect the `FunctionBody` variant of arrow functions, which were already correct due to the opening brace. Resolves #332. Test Plan: Type ```javascript const myNiftyArrowFunction = (foo, bar) => foo + bar; myNiftyArrowFunction(1, 2); ``` and note that it's indented correctly as you type. Then run `gg=G` and make sure that it stays indented correctly. Note also that the indentation of ```javascript const myFunctionBodiedArrowFunction = (foo, bar) => { doAThing(); return foo + bar; }; myFunctionBodiedArrowFunction(1, 2); ``` is still correct.
1 parent 255d5e6 commit 7b9e11a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

indent/javascript.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ let s:continuation_regex = '\%([\\*+/.:]\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\|[^=]
5555
" TODO: this needs to deal with if ...: and so on
5656
let s:msl_regex = s:continuation_regex.'|'.s:expr_case
5757

58-
let s:one_line_scope_regex = '\<\%(if\|else\|for\|while\)\>[^{;]*' . s:line_term
58+
let s:one_line_scope_regex = '\%(\<\%(if\|else\|for\|while\)\>\|=>\)[^{;]*' . s:line_term
5959

6060
" Regex that defines blocks.
6161
let s:block_regex = '\%([{[]\)\s*\%(|\%([*@]\=\h\w*,\=\s*\)\%(,\s*[*@]\=\h\w*\)*|\)\=' . s:line_term

0 commit comments

Comments
 (0)