Skip to content

Commit 27a37b4

Browse files
authored
for 585 (#586)
changes operator behavior inside of invoking parens, object literals, and arrays.
1 parent 6de8f62 commit 27a37b4

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

indent/javascript.vim

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,17 @@ function GetJavascriptIndent()
186186
if line =~ s:line_pre . '[])}]'
187187
return indent(num)
188188
endif
189-
let inb = num == 0 ? 1 : s:Onescope(num, s:StripLine(strpart(getline(num),0,b:js_cache[2] - 1)),1)
189+
190+
let pline = s:StripLine(getline(lnum))
191+
let inb = num == 0 ? 1 : s:Onescope(num, s:StripLine(strpart(getline(num),0,b:js_cache[2] - 1)),1) ||
192+
\ (num < lnum && (line !~ s:line_pre . ',' && pline !~ ',' . s:line_term))
190193
let switch_offset = (!inb || num == 0) || expand("<cword>") !=# 'switch' ? 0 : &cino !~ ':' || !has('float') ? s:sw() :
191194
\ float2nr(str2float(matchstr(&cino,'.*:\zs[-0-9.]*')) * (match(&cino,'.*:\zs[^,]*s') ? s:sw() : 1))
192-
let pline = s:StripLine(getline(lnum))
193-
if ((line =~# g:javascript_opfirst ||
194-
\ (pline =~# g:javascript_continuation && pline !~# s:expr_case &&
195-
\ (pline !~ ':' . s:line_term || line !~#
196-
\ s:line_pre . '\%(d\%(o\|ebugger\)\|else\|f\%(or\|inally\)\|if\|let\|switch\|t\%(hrow\|ry\)\|w\%(hile\|ith\)\)\>'))) &&
197-
\ inb) || (s:Onescope(lnum,pline,0) && line !~ s:line_pre . '{')
195+
196+
if (inb && (line =~# g:javascript_opfirst ||
197+
\ (pline =~# g:javascript_continuation && pline !~# s:expr_case && (pline !~ ':' . s:line_term || line !~#
198+
\ s:line_pre . '\%(d\%(o\|ebugger\)\|else\|f\%(or\|inally\)\|if\|let\|switch\|t\%(hrow\|ry\)\|w\%(hile\|ith\)\)\>')))) ||
199+
\ (num < lnum && s:Onescope(lnum,pline,0) && line !~ s:line_pre . '{')
198200
return (num > 0 ? indent(num) : -s:sw()) + (s:sw() * 2) + switch_offset
199201
elseif num > 0
200202
return indent(num) + s:sw() + switch_offset

0 commit comments

Comments
 (0)