@@ -389,20 +389,20 @@ function GetJavascriptIndent()
389389 return indent (prevline)
390390 end
391391 let counts = s: LineHasOpeningBrackets (prevline)
392- if counts[0 ] == ' 2'
392+ if counts[0 ] == ' 2' || counts[ 1 ] == ' 2 ' || counts[ 2 ] == ' 2 '
393393 call cursor (prevline, 1 )
394394 " 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 ( ' . ' ) )
398398 end
399399 elseif counts[0 ] != ' 1' && counts[1 ] != ' 1' && counts[2 ] != ' 1'
400400 " otherwise, indent 1 level
401401 return indent (prevline) + s: sw ()
402402 end
403+
403404 " 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
406406 let counts = s: LineHasOpeningBrackets (prevline)
407407 if counts[0 ] == ' 2' && ! s: Match (prevline, s: operator_first )
408408 call cursor (prevline, 1 )
@@ -412,14 +412,7 @@ function GetJavascriptIndent()
412412 return indent (mnum) - s: sw ()
413413 end
414414 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'
423416 return indent (prevline) - s: sw ()
424417 end
425418 end
0 commit comments