@@ -389,20 +389,20 @@ function GetJavascriptIndent()
389
389
return indent (prevline)
390
390
end
391
391
let counts = s: LineHasOpeningBrackets (prevline)
392
- if counts[0 ] == ' 2'
392
+ if counts[0 ] == ' 2' || counts[ 1 ] == ' 2 ' || counts[ 2 ] == ' 2 '
393
393
call cursor (prevline, 1 )
394
394
" Search for the opening tag
395
- let mnum = searchpair (' (' , ' ' , ' ) ' , ' bW ' , s: skip_expr )
396
- if mnum > 0 && s: Match (mnum , s: operator_first )
397
- return indent (mnum )
395
+ let bs = strpart (' (){}[] ' , stridx ( ' )}] ' , line [ col - 1 ]) * 2 , 2 )
396
+ if searchpair ( escape ( bs [ 0 ], ' \[ ' ), ' ' , bs [ 1 ], ' bW ' , s: skip_expr ) > 0 && s: Match (line ( ' . ' ) , s: operator_first )
397
+ return indent (line ( ' . ' ) )
398
398
end
399
399
elseif counts[0 ] != ' 1' && counts[1 ] != ' 1' && counts[2 ] != ' 1'
400
400
" otherwise, indent 1 level
401
401
return indent (prevline) + s: sw ()
402
402
end
403
+
403
404
" If previous line starts with an operator...
404
- elseif (s: Match (prevline, s: operator_first ) && getline (prevline) !~ s: continuation_regex &&
405
- \ getline (prevline) !~ ' };\=' . s: line_term ) || getline (prevline) = ~ ' );\=' . s: line_term
405
+ elseif (s: Match (prevline, s: operator_first ) && ! s: Match (prevline,s: continuation_regex ))|| getline (prevline) = ~ ' );\=' . s: line_term
406
406
let counts = s: LineHasOpeningBrackets (prevline)
407
407
if counts[0 ] == ' 2' && ! s: Match (prevline, s: operator_first )
408
408
call cursor (prevline, 1 )
@@ -412,14 +412,7 @@ function GetJavascriptIndent()
412
412
return indent (mnum) - s: sw ()
413
413
end
414
414
elseif s: Match (prevline, s: operator_first )
415
- if counts[0 ] == ' 2' && counts[1 ] == ' 1'
416
- call cursor (prevline, 1 )
417
- " Search for the opening tag
418
- let mnum = searchpair (' (' , ' ' , ' )' , ' bW' , s: skip_expr )
419
- if mnum > 0 && ! s: Match (mnum, s: operator_first )
420
- return indent (mnum) + s: sw ()
421
- end
422
- elseif counts[0 ] != ' 1' && counts[1 ] != ' 1' && counts[2 ] != ' 1'
415
+ if counts[0 ] != ' 1' && counts[1 ] != ' 1' && counts[2 ] != ' 1'
423
416
return indent (prevline) - s: sw ()
424
417
end
425
418
end
0 commit comments