Skip to content

Commit 92f1d98

Browse files
authored
switch accuracy and performance (#647)
1 parent dc67840 commit 92f1d98

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

indent/javascript.vim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ else
3838
endif
3939

4040
let s:line_pre = '^\s*\%(\%(\%(\/\*.\{-}\)\=\*\+\/\s*\)\=\)\@>'
41-
let s:expr_case = s:line_pre . '\%(\%(case\>.\+\)\|default\)\s*:\C'
41+
let s:expr_case = '\<\%(\%(case\>.\+\)\|default\)\s*:\C'
4242
" Regex of syntax group names that are or delimit string or are comments.
4343
let s:syng_strcom = '\%(s\%(tring\|pecial\)\|comment\|regex\|doc\|template\)'
4444

@@ -170,16 +170,16 @@ function GetJavascriptIndent()
170170
return 0
171171
endif
172172

173-
if l:line =~# s:expr_case
173+
let l:line = substitute(l:line,s:line_pre,'','')
174+
175+
if l:line =~# '^' . s:expr_case
174176
let cpo_switch = &cpo
175177
set cpo+=%
176178
let ind = cindent(v:lnum)
177179
let &cpo = cpo_switch
178180
return ind
179181
endif
180182

181-
let l:line = substitute(l:line,s:line_pre,'','')
182-
183183
" the containing paren, bracket, curly. Memoize, last lineNr either has the
184184
" same scope or starts a new one, unless if it closed a scope.
185185
call cursor(v:lnum,1)

0 commit comments

Comments
 (0)