Skip to content

Commit b0237b0

Browse files
authored
other small touches (#677)
1 parent 53f843b commit b0237b0

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Diff for: indent/javascript.vim

+6-7
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ function GetJavascriptIndent()
199199
return -1
200200
endif
201201
let l:lnum = s:PrevCodeLine(v:lnum - 1)
202-
if l:lnum == 0
202+
if !l:lnum
203203
return 0
204204
endif
205205

@@ -215,15 +215,14 @@ function GetJavascriptIndent()
215215

216216
" the containing paren, bracket, curly. Many hacks for performance
217217
call cursor(v:lnum,1)
218-
let fclose = l:line =~ '^[])}]'
218+
let idx = stridx('])}',l:line[0])
219219
if indent(l:lnum)
220220
let [s:looksyn,s:free] = [v:lnum - 1,1]
221221
if b:js_cache[0] >= l:lnum && b:js_cache[0] < v:lnum &&
222-
\ (b:js_cache[0] > l:lnum || !fclose && s:Balanced(l:lnum))
222+
\ (b:js_cache[0] > l:lnum || idx < 0 && s:Balanced(l:lnum))
223223
let num = b:js_cache[1]
224-
elseif fclose
225-
let id = stridx('])}',l:line[0])
226-
return indent(s:GetPair(escape('[({'[id],'['), '])}'[id],'bW','s:skip_func(s:looksyn)',2000))
224+
elseif idx + 1
225+
return indent(s:GetPair(escape('[({'[idx],'['), '])}'[idx],'bW','s:skip_func(s:looksyn)',2000))
227226
elseif indent(v:lnum) && syns =~? 'block'
228227
let num = s:GetPair('{','}','bW','s:skip_func(s:looksyn)',2000)
229228
else
@@ -233,7 +232,7 @@ function GetJavascriptIndent()
233232
let num = s:GetPair('[({[]','[])}]','bW',s:skip_expr,200,l:lnum)
234233
endif
235234

236-
if fclose
235+
if idx + 1
237236
return indent(num)
238237
endif
239238
let num = max([num,0])

0 commit comments

Comments
 (0)