From 7f24bad6b7094e34c9bd05932c1bcc3ababb6311 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Sun, 25 Sep 2016 19:16:52 -0700 Subject: [PATCH] switch accuracy and performance --- indent/javascript.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index c6d5e110..e89e493d 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -38,7 +38,7 @@ else endif let s:line_pre = '^\s*\%(\%(\%(\/\*.\{-}\)\=\*\+\/\s*\)\=\)\@>' -let s:expr_case = s:line_pre . '\%(\%(case\>.\+\)\|default\)\s*:\C' +let s:expr_case = '\<\%(\%(case\>.\+\)\|default\)\s*:\C' " Regex of syntax group names that are or delimit string or are comments. let s:syng_strcom = '\%(s\%(tring\|pecial\)\|comment\|regex\|doc\|template\)' @@ -170,7 +170,9 @@ function GetJavascriptIndent() return 0 endif - if l:line =~# s:expr_case + let l:line = substitute(l:line,s:line_pre,'','') + + if l:line =~# '^' . s:expr_case let cpo_switch = &cpo set cpo+=% let ind = cindent(v:lnum) @@ -178,8 +180,6 @@ function GetJavascriptIndent() return ind endif - let l:line = substitute(l:line,s:line_pre,'','') - " the containing paren, bracket, curly. Memoize, last lineNr either has the " same scope or starts a new one, unless if it closed a scope. call cursor(v:lnum,1)