Skip to content

Commit 336d435

Browse files
authored
more cleaning
1 parent 6a3fac4 commit 336d435

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

indent/javascript.vim

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ endfunction
8383

8484
" strip line of comment
8585
function s:StripLine(c)
86-
return substitute(a:c, '\%(:\@<!\/\/.*\)$', '','')
86+
return a:c !~ s:expr_case ? substitute(a:c, '\%(:\@<!\/\/.*\)$', '','') : a:c
8787
endfunction
8888

8989
" Check if the character at lnum:col is inside a string, comment, or is ascii.
@@ -147,7 +147,6 @@ function GetJavascriptIndent()
147147
if lnum == 0
148148
return 0
149149
endif
150-
let line = s:StripLine(line)
151150

152151
if (line =~# s:expr_case)
153152
let cpo_switch = &cpo
@@ -164,15 +163,15 @@ function GetJavascriptIndent()
164163
let pcounts = [0]
165164
if b:js_cache[0] >= lnum && b:js_cache[0] <= v:lnum && b:js_cache[0] &&
166165
\ (b:js_cache[0] > lnum || map(pcounts,'s:LineHasOpeningBrackets(lnum)')[0] !~ '2')
167-
let num = pcounts[0] =~ '1' ? s:lookForParens('(\|{\|\[',')\|}\|\]','bW',2000) : b:js_cache[1]
166+
let num = pcounts[0] =~ '1' ? s:lookForParens('[({[]','[])}]','bW',2000) : b:js_cache[1]
168167
else
169168
let syns = synIDattr(synID(v:lnum, 1, 1), 'name')
170169
if line[0] =~ '\s' && syns != ''
171170
let pattern = syns =~? 'funcblock' ? ['{','}'] : syns =~? 'jsparen' ? ['(',')'] : syns =~? 'jsbracket'? ['\[','\]'] :
172-
\ ['(\|{\|\[',')\|}\|\]']
171+
\ ['[({[]','[])}]']
173172
let num = s:lookForParens(pattern[0],pattern[1],'bW',2000)
174173
else
175-
let num = s:lookForParens('(\|{\|\[',')\|}\|\]','bW',2000)
174+
let num = s:lookForParens('[({[]','[])}]','bW',2000)
176175
endif
177176
endif
178177
let b:js_cache = [v:lnum,num,line('.') == v:lnum ? b:js_cache[2] : col('.')]

0 commit comments

Comments
 (0)