From 328849776c4080b536d7fbe98db4f3e23d1fbbb6 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Wed, 7 Sep 2016 12:25:39 -0700 Subject: [PATCH 1/2] little optimizations --- indent/javascript.vim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index f0cca94d..3fa28fdf 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*:' +let s:expr_case = s:line_pre . '\%(\%(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\)' @@ -180,15 +180,16 @@ function GetJavascriptIndent() return indent(num) endif - let pline = getline(l:lnum) =~# s:expr_case ? getline(l:lnum) : substitute(getline(l:lnum), '\%(:\@' && - \ l:line !~ s:line_pre . '{') && (num == 0 || cursor(b:js_cache[1],b:js_cache[2]) || s:IsBlock()) + \ l:line !~ s:line_pre . '{' let b:js_cache[3] = (num > 0 ? indent(num) : -s:sw()) + (s:sw() * 2) + switch_offset return b:js_cache[3] + known elseif num > 0 From f68d378a91fe60317dfbcfd85c5e82e874de3fe3 Mon Sep 17 00:00:00 2001 From: Chris Paul Date: Wed, 7 Sep 2016 19:03:17 -0700 Subject: [PATCH 2/2] extra parens --- indent/javascript.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indent/javascript.vim b/indent/javascript.vim index 3fa28fdf..d214f29b 100644 --- a/indent/javascript.vim +++ b/indent/javascript.vim @@ -186,7 +186,7 @@ function GetJavascriptIndent() \ float2nr(str2float(matchstr(&cino,'.*:\zs[-0-9.]*')) * (&cino =~# '.*:[^,]*s' ? s:sw() : 1)) " most significant, find the indent amount - if ((l:line =~# g:javascript_opfirst || pline =~# g:javascript_continuation)) && + if (l:line =~# g:javascript_opfirst || pline =~# g:javascript_continuation) && \ (num == 0 || cursor(b:js_cache[1],b:js_cache[2]) || s:IsBlock()) || \ s:OneScope(l:lnum,pline,0) =~# '\<\%(for\|each\|if\|let\|no\sb\|w\%(hile\|ith\)\)\>' && \ l:line !~ s:line_pre . '{'