@@ -153,9 +153,21 @@ function s:GetMSL(lnum, in_one_line_scope)
153
153
" Otherwise, terminate search as we have found our MSL already.
154
154
let line = getline (lnum)
155
155
let col = match (line , s: msl_regex ) + 1
156
+ let line2 = getline (msl)
157
+ let col2 = matchend (line2, ' )' )
156
158
if (col > 0 && ! s: IsInStringOrComment (lnum, col )) || s: IsInString (lnum, strlen (line ))
157
159
let msl = lnum
160
+
161
+ " if there are more closing brackets, continue from the line which has the matching opening bracket
162
+ elseif col2 > 0 && ! s: IsInStringOrComment (msl, col2) && s: LineHasOpeningBrackets (msl)[0 ] == ' 2'
163
+ call cursor (msl, 1 )
164
+ if searchpair (' (' , ' ' , ' )' , ' bW' , s: skip_expr ) > 0
165
+ let lnum = line (' .' )
166
+ let msl = lnum
167
+ endif
168
+
158
169
else
170
+
159
171
" Don't use lines that are part of a one line scope as msl unless the
160
172
" flag in_one_line_scope is set to 1
161
173
"
@@ -166,7 +178,7 @@ function s:GetMSL(lnum, in_one_line_scope)
166
178
if msl_one_line == 0
167
179
break
168
180
endif
169
- endif
181
+ end
170
182
let lnum = s: PrevNonBlankNonString (lnum - 1 )
171
183
endwhile
172
184
return msl
@@ -404,7 +416,7 @@ function GetJavascriptIndent()
404
416
return indent (prevline) + s: sw ()
405
417
end
406
418
" If previous line starts with an operator...
407
- elseif s: Match (prevline, s: operator_first ) && ! s: Match (prevline, s: comma_last )
419
+ elseif s: Match (prevline, s: operator_first ) && ! s: Match (prevline, s: comma_last ) && ! s: Match (prevline, ' };\= ' . s: line_term )
408
420
let counts = s: LineHasOpeningBrackets (prevline)
409
421
if counts[0 ] == ' 2' && counts[1 ] == ' 1'
410
422
call cursor (prevline, 1 )
@@ -488,7 +500,14 @@ function GetJavascriptIndent()
488
500
else
489
501
call cursor (v: lnum , vcol)
490
502
end
491
- elseif line = ~ ' )' || line = ~ s: comma_last
503
+ elseif line = ~ ' .\+};\=' . s: line_term
504
+ call cursor (lnum, 1 )
505
+ " Search for the opening tag
506
+ let mnum = searchpair (' {' , ' ' , ' }' , ' bW' , s: skip_expr )
507
+ if mnum > 0
508
+ return indent (s: GetMSL (mnum, 0 ))
509
+ end
510
+ elseif line = ~ ' .\+);\=' || line = ~ s: comma_last
492
511
let counts = s: LineHasOpeningBrackets (lnum)
493
512
if counts[0 ] == ' 2'
494
513
call cursor (lnum, 1 )
@@ -497,7 +516,7 @@ function GetJavascriptIndent()
497
516
if mnum > 0
498
517
return indent (s: GetMSL (mnum, 0 ))
499
518
end
500
- elseif line !~ s: var_stmt
519
+ elseif line !~ s: var_stmt
501
520
return indent (prevline)
502
521
end
503
522
end
0 commit comments