4343
4444let s: line_pre = ' ^\s*\%(\/\*.*\*\/\s*\)*'
4545let s: js_keywords = s: line_pre . ' \%(break\|import\|export\|catch\|const\|continue\|debugger\|delete\|do\|else\|finally\|for\|function\|if\|in\|instanceof\|let\|new\|return\|switch\|this\|throw\|try\|typeof\|var\|void\|while\|with\)\>\C'
46- let s: expr_case = s: line_pre . ' \%(case\s\+[^\:]*\ |default\)\s*:\s* \C'
46+ let s: expr_case = s: line_pre . ' \%(\%( case\>.*\)\ |default\)\s*:\C'
4747" Regex of syntax group names that are or delimit string or are comments.
4848let s: syng_strcom = ' \%(string\|regex\|special\|doc\|comment\|template\)\c'
4949
@@ -337,7 +337,7 @@ function GetJavascriptIndent()
337337 endif
338338
339339 " single opening bracket will assume you want a c style of indenting
340- if s: Match ( v: lnum , s: line_pre . ' {' . s: line_term) && ! s: Match (lnum,s: block_regex ) &&
340+ if line = ~ s: line_pre . ' {' . s: line_term && ! s: Match (lnum,s: block_regex ) &&
341341 \ ! s: Match (lnum,s: comma_last )
342342 return cindent (v: lnum )
343343 endif
@@ -353,7 +353,7 @@ function GetJavascriptIndent()
353353
354354 " If we got a closing bracket on an empty line, find its match and indent
355355 " according to it.
356- let col = s: Match ( v: lnum , s: line_pre . ' []})]' )
356+ let col = line = ~ s: line_pre . ' []})]'
357357 if col > 0
358358 let parlnum = v: lnum
359359 while col
@@ -395,12 +395,12 @@ function GetJavascriptIndent()
395395 end
396396
397397 " If previous line starts with an operator...
398- elseif (s: Match (lnum, s: operator_first ) && ! s: Match (lnum,s: continuation_regex ))|| getline (lnum) = ~ ' ) ;\=' . s: line_term
398+ elseif (s: Match (lnum, s: operator_first ) && ! s: Match (lnum,s: continuation_regex ))|| getline (lnum) = ~ ' []})] ;\=' . s: line_term
399399 let counts = s: LineHasOpeningBrackets (lnum)
400- if counts[ 0 ] == ' 2' && ! s: Match (lnum, s: operator_first )
400+ if counts = ~ ' 2' && ! s: Match (lnum, s: operator_first )
401401 call cursor (lnum, 1 )
402402 " Search for the opening tag
403- let mnum = s: lookForParens (' (' , ' )' , ' nbW' , 0 )
403+ let mnum = s: lookForParens (' (\|{\|\[ ' , ' )\|}\|\] ' , ' nbW' , 0 )
404404 if mnum > 0 && s: Match (mnum, s: operator_first )
405405 return indent (mnum) - s: sw ()
406406 end
@@ -434,16 +434,6 @@ function GetJavascriptIndent()
434434 return 0
435435 endif
436436
437- " foo('foo',
438- " bar('bar', function() {
439- " hi();
440- " })
441- " );
442-
443- " function (a, b, c, d,
444- " e, f, g) {
445- " console.log('inner');
446- " }
447437 " If the previous line ended with a block opening, add a level of indent.
448438 if s: Match (lnum, s: block_regex )
449439 return s: InMultiVarStatement (lnum, 0 , 0 ) || s: LineHasOpeningBrackets (lnum) !~ ' 2' ?
@@ -463,7 +453,8 @@ function GetJavascriptIndent()
463453 call cursor (lnum, matchend (s: RemoveTrailingComments (strpart (line ,0 ,col (' .' ))), ' .*\zs[])}]' ))
464454 endwhile
465455 let cur = line (' .' )
466- if cur < lnum && ! s: InMultiVarStatement (cur,0 ,0 )
456+ if cur < lnum && ! s: InMultiVarStatement (cur,0 ,0 ) &&
457+ \ ! s: Onescope (s: PrevNonBlankNonString (cur - 1 ))
467458 return indent (s: GetMSL (cur, 0 ))
468459 end
469460 elseif counts = ~ ' 1' || s: Onescope (lnum)
0 commit comments