Skip to content

Commit c516241

Browse files
authored
more variables
1 parent e4452cf commit c516241

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

indent/javascript.vim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ function GetJavascriptIndent()
265265
let s:W = s:sw()
266266
let pline = s:Trimline(l:lnum)
267267
call cursor(b:js_cache[1],b:js_cache[2])
268-
let switch_offset = !num || !(search(')\_s*\%#','bW') &&
268+
let bchar = getline(b:js_cache[1])[b:js_cache[2]-1] == '{'
269+
let switch_offset = !num || !bchar || !(search(')\_s*\%#','bW') &&
269270
\ s:GetPair('(', ')', 'bW', s:skip_expr, 100) > 0 && search('\C\<switch\_s*\%#','bW')) ? 0 :
270271
\ &cino !~ ':' || !has('float') ? s:W :
271272
\ float2nr(str2float(matchstr(&cino,'.*:\zs[-0-9.]*')) * (&cino =~# '.*:[^,]*s' ? s:W : 1))
@@ -274,7 +275,7 @@ function GetJavascriptIndent()
274275
let isOp = l:line =~# g:javascript_opfirst || pline !~# s:expr_case . '$' && pline =~# g:javascript_continuation
275276
let bL = s:iscontOne(l:lnum,num,isOp)
276277
let bL -= (bL && l:line =~ '^{') * s:W
277-
if isOp && (!num || cursor(b:js_cache[1],b:js_cache[2]) || (getline(line('.'))[col('.')-1] == '{' && s:IsBlock()))
278+
if isOp && (!num || cursor(b:js_cache[1],b:js_cache[2]) || (bchar && s:IsBlock()))
278279
return (num ? indent(num) : -s:W) + (s:W * 2) + switch_offset + bL
279280
elseif num
280281
return indent(num) + s:W + switch_offset + bL

0 commit comments

Comments
 (0)