@@ -69,7 +69,7 @@ let s:msl_regex = s:continuation_regex.'\|'.s:expr_case
69
69
let s: one_line_scope_regex = ' \%(\%(\<else\>\|\<\%(if\|for\|while\)\>\s*(.*)\)\|=>\)' . s: line_term
70
70
71
71
" Regex that defines blocks.
72
- let s: block_regex = ' \%([{[]\)\s*\%(|\%([*@]\=\h\w*,\=\s*\)\%(,\s*[*@]\=\h\w*\)*|\)\=' . s: line_term
72
+ let s: block_regex = ' \%([{( []\)\s*\%(|\%([*@]\=\h\w*,\=\s*\)\%(,\s*[*@]\=\h\w*\)*|\)\=' . s: line_term
73
73
74
74
let s: var_stmt = ' ^\s*(const\|let\|var)'
75
75
@@ -240,7 +240,7 @@ function s:LineHasOpeningBrackets(lnum)
240
240
endif
241
241
let pos = match (line , ' [][(){}]' , pos + 1 )
242
242
endwhile
243
- return (open_0 > 0 ) . (open_2 > 0 ) . (open_4 > 0 )
243
+ return (open_0 > 0 ? 1 :(open_0 == 0 ? 0 : 2 ) ) . (open_2 > 0 ) . (open_4 > 0 )
244
244
endfunction
245
245
246
246
function s: Match (lnum, regex)
@@ -302,6 +302,7 @@ function s:ExitingOneLineScope(lnum)
302
302
return 0
303
303
endfunction
304
304
305
+
305
306
" 3. GetJavascriptIndent Function {{{1
306
307
" =========================
307
308
@@ -438,9 +439,7 @@ function GetJavascriptIndent()
438
439
if line = ~ ' [[({]'
439
440
let counts = s: LineHasOpeningBrackets (lnum)
440
441
if counts[0 ] == ' 1' && searchpair (' (' , ' ' , ' )' , ' bW' , s: skip_expr ) > 0
441
- if col (' .' ) + 1 == col (' $' )
442
- return ind + s: sw ()
443
- else
442
+ if col (' .' ) + 1 != col (' $' )
444
443
return virtcol (' .' )
445
444
endif
446
445
elseif counts[1 ] == ' 1' || counts[2 ] == ' 1'
@@ -450,6 +449,20 @@ function GetJavascriptIndent()
450
449
end
451
450
endif
452
451
452
+ if line = ~ ' )'
453
+ let counts = s: LineHasOpeningBrackets (lnum)
454
+ if counts[0 ] == ' 2'
455
+ let curpos = getpos (" ." )
456
+ call cursor (lnum, 1 )
457
+ " Search for the opening tag
458
+ let mnum = searchpair (' (' , ' ' , ' )' , ' bW' , s: skip_expr )
459
+ " Restore the cursor position
460
+ call cursor (curpos)
461
+ if mnum > 0
462
+ return indent (mnum)
463
+ end
464
+ end
465
+ endif
453
466
" 3.4. Work on the MSL line. {{{2
454
467
" --------------------------
455
468
0 commit comments