@@ -76,7 +76,7 @@ function s:Onescope(lnum,text,add)
7676 \ cursor (line (' .' ),match ( ' ' . strpart (getline (line (' .' )),0 ,col (' .' ) - 1 ),
7777 \ (a: add ? ' \K\k*' :
7878 \ ' \<\%(else\|for\%(\s+each\)\=\|function\*\=\%(\s\+\K\k*\)\=\|if\|let\|switch\|while\|with\)\C' ) . s: line_term )) > -1 ) &&
79- \ (a: add || (expand (" <cword>" ) = ~ ' while\C ' ? ! s: lookForParens (' \<do\>\C' , ' \<while\>\C' ,' bW' ,100 ) : 1 ))
79+ \ (a: add || (expand (" <cword>" ) == ' while' ? ! s: lookForParens (' \<do\>\C' , ' \<while\>\C' ,' bW' ,100 ) : 1 ))
8080endfunction
8181
8282" Auxiliary Functions {{{2
@@ -183,16 +183,12 @@ function GetJavascriptIndent()
183183 if line = ~ s: line_pre . ' [])}]'
184184 return indent (num)
185185 end
186- let switch_offset = 0
187- if index (map (synstack (v: lnum , 1 ), ' synIDattr( v:val, "name")' ),' jsSwitchBlock' ) > -1
188- let bnum = search (' \<switch\s*(' ,' nbW' )
189- let switch_offset = bnum < num || bnum == lnum ? 0 : &cino !~ ' :' || ! has (' float' ) ? s: sw () :
190- \ float2nr (str2float (matchstr (&cino ,' .*:\zs[-0-9.]*' )) * (match (&cino ,' .*:\zs[^,]*s' ) ? s: sw () : 1 ))
191- endif
186+ let inb = num == 0 ? 1 : s: Onescope (num, strpart (getline (num),0 ,b: js_cache [2 ] - 1 ),1 )
187+ let switch_offset = (! inb || num == 0 ) || expand (" <cword>" ) != ' switch' ? 0 : &cino !~ ' :' || ! has (' float' ) ? s: sw () :
188+ \ float2nr (str2float (matchstr (&cino ,' .*:\zs[-0-9.]*' )) * (match (&cino ,' .*:\zs[^,]*s' ) ? s: sw () : 1 ))
192189 if ((line = ~ g: javascript_opfirst ||
193190 \ (getline (lnum) = ~ g: javascript_continuation && getline (lnum) !~ s: expr_case )) &&
194- \ (num == 0 || s: Onescope (num, strpart (getline (num),0 ,b: js_cache [2 ] - 1 ),1 ))) ||
195- \ (s: Onescope (lnum,getline (lnum),0 ) && line !~ s: line_pre . ' {' )
191+ \ inb) || (s: Onescope (lnum,getline (lnum),0 ) && line !~ s: line_pre . ' {' )
196192 return (num > 0 ? indent (num) : - s: sw ()) + (s: sw () * 2 ) + switch_offset
197193 elseif num > 0
198194 return indent (num) + s: sw () + switch_offset
0 commit comments