@@ -178,6 +178,8 @@ function GetJavascriptIndent()
178
178
return ind
179
179
endif
180
180
181
+ let l: line = substitute (l: line ,s: line_pre ,' ' ,' ' )
182
+
181
183
" the containing paren, bracket, curly. Memoize, last lineNr either has the
182
184
" same scope or starts a new one, unless if it closed a scope.
183
185
call cursor (v: lnum ,1 )
@@ -186,7 +188,10 @@ function GetJavascriptIndent()
186
188
if b: js_cache [0 ] < v: lnum && b: js_cache [0 ] >= l: lnum &&
187
189
\ (b: js_cache [0 ] > l: lnum || s: Balanced (l: lnum ))
188
190
let num = b: js_cache [1 ]
189
- elseif syns != ' ' && l: line [0 ] = ~ ' \s'
191
+ elseif l: line = ~ ' ^[])}]'
192
+ let id = stridx (' ])}' ,l: line [0 ])
193
+ let num = s: GetPair (escape (' [({' [id],' [' ), escape (' ])}' [id],' ]' ),' bW' ,' s:skip_func(s:looksyn)' ,2000 )
194
+ elseif syns != ' ' && getline (v: lnum )[0 ] = ~ ' \s'
190
195
let pattern = syns = ~? ' block' ? [' {' ,' }' ] : syns = ~? ' jsparen' ? [' (' ,' )' ] :
191
196
\ syns = ~? ' jsbracket' ? [' \[' ,' \]' ] : [' [({[]' ,' [])}]' ]
192
197
let num = s: GetPair (pattern[0 ],pattern[1 ],' bW' ,' s:skip_func(s:looksyn)' ,2000 )
@@ -200,7 +205,6 @@ function GetJavascriptIndent()
200
205
let num = (num > 0 ) * num
201
206
let b: js_cache = [v: lnum ,num,line (' .' ) == v: lnum ? b: js_cache [2 ] : col (' .' )]
202
207
203
- let l: line = substitute (l: line ,s: line_pre ,' ' ,' ' )
204
208
if l: line = ~ ' ^[])}]'
205
209
return ! ! num * indent (num)
206
210
endif
0 commit comments