Skip to content

Commit 0115077

Browse files
authored
accurate switch indenting (#499)
since cindent considers single quotes as delimiting a single char string, cindent will break in situations like : https://github.com/sanctuary-js/sanctuary-def/blob/master/index.js#L222 http://stackoverflow.com/questions/3683602/single-quotes-vs-double-quotes-in-c
1 parent 420f98c commit 0115077

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

indent/javascript.vim

+5-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,11 @@ function GetJavascriptIndent()
344344

345345
" cindent each line which has a switch label
346346
if (line =~ s:expr_case)
347-
return cindent(v:lnum)
347+
let s:cpo_switch = &cpo
348+
set cpo+=%
349+
let ind = cindent(v:lnum)
350+
let &cpo = s:cpo_switch
351+
return ind
348352
endif
349353

350354
" If we got a closing bracket on an empty line, find its match and indent

0 commit comments

Comments
 (0)