Skip to content

Commit 817215b

Browse files
authored
more code cleaning
1 parent 2ef9a9c commit 817215b

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

indent/javascript.vim

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -241,23 +241,19 @@ function GetJavascriptIndent()
241241
let num = b:js_cache[1]
242242

243243
let [s:W, pline, isOp, stmt, bL, switch_offset] = [s:sw(), s:Trim(l:lnum),0,0,0,0]
244-
if num
245-
if s:current_char() == '{' && s:IsBlock()
246-
let stmt = 1
247-
if s:current_char() == ')' && s:GetPair('(', ')', 'bW', s:skip_expr, 100) > 0 && s:previous_token() ==# 'switch'
248-
let switch_offset = &cino !~ ':' || !has('float') ? s:W :
249-
\ float2nr(str2float(matchstr(&cino,'.*:\zs[-0-9.]*')) * (&cino =~# '.*:[^,]*s' ? s:W : 1))
250-
if l:line =~# '^' . s:expr_case
251-
return indent(num) + switch_offset
252-
endif
253-
let stmt = pline !~# s:expr_case . '$'
244+
if num && s:current_char() == '{' && s:IsBlock()
245+
let stmt = 1
246+
if s:current_char() == ')' && s:GetPair('(', ')', 'bW', s:skip_expr, 100) > 0 && s:previous_token() ==# 'switch'
247+
let switch_offset = &cino !~ ':' || !has('float') ? s:W :
248+
\ float2nr(str2float(matchstr(&cino,'.*:\zs[-0-9.]*')) * (&cino =~# '.*:[^,]*s' ? s:W : 1))
249+
if l:line =~# '^' . s:expr_case
250+
return indent(num) + switch_offset
254251
endif
252+
let stmt = pline !~# s:expr_case . '$'
255253
endif
256-
else
257-
let stmt = 1
258254
endif
259255

260-
if stmt
256+
if stmt || !num
261257
call cursor(v:lnum,1)
262258
if l:line =~# '^while\>' && s:GetPair('\C\<do\>','\C\<while\>','bW',s:skip_expr . '|| !s:IsBlock()',100,num + 1) > 0
263259
return indent(line('.'))

0 commit comments

Comments
 (0)