Skip to content

for 585 #586

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
Aug 3, 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
16 changes: 9 additions & 7 deletions indent/javascript.vim
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,17 @@ function GetJavascriptIndent()
if line =~ s:line_pre . '[])}]'
return indent(num)
endif
let inb = num == 0 ? 1 : s:Onescope(num, s:StripLine(strpart(getline(num),0,b:js_cache[2] - 1)),1)

let pline = s:StripLine(getline(lnum))
let inb = num == 0 ? 1 : s:Onescope(num, s:StripLine(strpart(getline(num),0,b:js_cache[2] - 1)),1) ||
\ (num < lnum && (line !~ s:line_pre . ',' && pline !~ ',' . s:line_term))
let switch_offset = (!inb || num == 0) || expand("<cword>") !=# 'switch' ? 0 : &cino !~ ':' || !has('float') ? s:sw() :
\ float2nr(str2float(matchstr(&cino,'.*:\zs[-0-9.]*')) * (match(&cino,'.*:\zs[^,]*s') ? s:sw() : 1))
let pline = s:StripLine(getline(lnum))
if ((line =~# g:javascript_opfirst ||
\ (pline =~# g:javascript_continuation && pline !~# s:expr_case &&
\ (pline !~ ':' . s:line_term || line !~#
\ s:line_pre . '\%(d\%(o\|ebugger\)\|else\|f\%(or\|inally\)\|if\|let\|switch\|t\%(hrow\|ry\)\|w\%(hile\|ith\)\)\>'))) &&
\ inb) || (s:Onescope(lnum,pline,0) && line !~ s:line_pre . '{')

if (inb && (line =~# g:javascript_opfirst ||
\ (pline =~# g:javascript_continuation && pline !~# s:expr_case && (pline !~ ':' . s:line_term || line !~#
\ s:line_pre . '\%(d\%(o\|ebugger\)\|else\|f\%(or\|inally\)\|if\|let\|switch\|t\%(hrow\|ry\)\|w\%(hile\|ith\)\)\>')))) ||
\ (num < lnum && s:Onescope(lnum,pline,0) && line !~ s:line_pre . '{')
return (num > 0 ? indent(num) : -s:sw()) + (s:sw() * 2) + switch_offset
elseif num > 0
return indent(num) + s:sw() + switch_offset
Expand Down