Skip to content

Commit bc86cbb

Browse files
authored
forward parse for switch statement (#1051)
* forward parse for switch statement * Update javascript.vim
1 parent de388ef commit bc86cbb

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

indent/javascript.vim

+2-4
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,8 @@ function s:IsContOne(num,cont)
282282
endfunction
283283

284284
function s:IsSwitch()
285-
return s:PreviousToken() !~ '[.*]' &&
286-
\ (!s:GetPair('{','}','cbW',s:skip_expr) || s:IsBlock() &&
287-
\ (s:Token() !=# 'class' && s:PreviousToken() !~# '^class$\|^extends$' ||
288-
\ s:PreviousToken() == '.'))
285+
call call('cursor',b:js_cache[1:])
286+
return search('\m\C\%#.\_s*\%(\%(\/\/.*\_$\|\/\*\_.\{-}\*\/\)\@>\_s*\)*\%(case\|default\)\>','nWc'.s:z)
289287
endfunction
290288

291289
" https://github.com/sweet-js/sweet.js/wiki/design#give-lookbehind-to-the-reader

0 commit comments

Comments
 (0)