Skip to content

Commit 63daab7

Browse files
authored
better &cino parsing (pangloss#759)
1 parent 8e17e23 commit 63daab7

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

indent/javascript.vim

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,12 @@ function GetJavascriptIndent()
269269
if num && s:looking_at() == ')' && s:GetPair('(', ')', 'bW', s:skip_expr, 100) > 0
270270
let num = line('.')
271271
if s:previous_token() ==# 'switch'
272-
let switch_offset = &cino !~ ':' || !has('float') ? s:W :
273-
\ float2nr(str2float(matchstr(&cino,'.*:\zs[-0-9.]*')) * (&cino =~# '\%(.*:\)\@>[^,]*s' ? s:W : 1))
272+
if &cino !~ ':' || !has('float')
273+
let switch_offset = s:W
274+
else
275+
let cinc = matchlist(&cino,'.*:\(-\)\=\([0-9.]*\)\(s\)\=\C')
276+
let switch_offset = float2nr(str2float(cinc[1].(strlen(cinc[2]) ? cinc[2] : 1)) * (strlen(cinc[3]) ? s:W : 1))
277+
endif
274278
if pline[-1:] != '.' && l:line =~# '^' . s:case_stmt
275279
return indent(num) + switch_offset
276280
elseif pline =~# s:case_stmt . '$'

0 commit comments

Comments
 (0)