Skip to content

other small touches #677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 21, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions indent/javascript.vim
Original file line number Diff line number Diff line change
@@ -199,7 +199,7 @@ function GetJavascriptIndent()
return -1
endif
let l:lnum = s:PrevCodeLine(v:lnum - 1)
if l:lnum == 0
if !l:lnum
return 0
endif

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

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

if fclose
if idx + 1
return indent(num)
endif
let num = max([num,0])