Skip to content

Commit 0ab4b1d

Browse files
authored
small fix
1 parent 89b5505 commit 0ab4b1d

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

indent/javascript.vim

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,14 @@ function GetJavascriptIndent()
186186
\ float2nr(str2float(matchstr(&cino,'.*:\zs[-0-9.]*')) * (&cino =~# '.*:[^,]*s' ? s:sw() : 1))
187187

188188
" most significant, find the indent amount
189-
if (l:line =~# g:javascript_opfirst || pline =~# g:javascript_continuation) &&
190-
\ (num == 0 || cursor(b:js_cache[1],b:js_cache[2]) || s:IsBlock()) ||
189+
let isOp = l:line =~# g:javascript_opfirst || pline =~# g:javascript_continuation
190+
if isOp && (num == 0 || cursor(b:js_cache[1],b:js_cache[2]) || s:IsBlock()) ||
191191
\ s:OneScope(l:lnum,pline,0) =~# '\<\%(for\|each\|if\|let\|no\sb\|w\%(hile\|ith\)\)\>' &&
192192
\ l:line !~ s:line_pre . '{'
193193
return (num > 0 ? indent(num) : -s:sw()) + (s:sw() * 2) + switch_offset
194194
elseif num > 0
195195
let b:js_cache[3] = indent(num) + s:sw() + switch_offset
196-
return b:js_cache[3] + known
196+
return b:js_cache[3] + (isOp ? known : 0)
197197
endif
198198

199199
endfunction

0 commit comments

Comments
 (0)