Skip to content

Commit b53274d

Browse files
authored
more small improvements
1 parent 81d8502 commit b53274d

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
@@ -157,7 +157,7 @@ function GetJavascriptIndent()
157157
" same scope or starts a new one, unless if it closed a scope.
158158
call cursor(v:lnum,1)
159159
if b:js_cache[0] < v:lnum && b:js_cache[0] >= l:lnum &&
160-
\ (s:Balanced(l:lnum) > 0 || b:js_cache[0] > l:lnum)
160+
\ (b:js_cache[0] > l:lnum || s:Balanced(l:lnum) > 0)
161161
let num = b:js_cache[1]
162162
elseif syns != '' && l:line[0] =~ '\s'
163163
let pattern = syns =~? 'block' ? ['{','}'] : syns =~? 'jsparen' ? ['(',')'] :
@@ -174,13 +174,13 @@ function GetJavascriptIndent()
174174
endif
175175

176176
let pline = substitute(substitute(getline(l:lnum),s:expr_case,'\=repeat(" ",strlen(submatch(0)))',''), '\%(:\@<!\/\/.*\)$', '','')
177-
let switch_offset = num == 0 || s:OneScope(num, strpart(getline(num),0,b:js_cache[2] - 1),1) !=# 'switch' ? 0 :
177+
let switch_offset = num <= 0 || s:OneScope(num, strpart(getline(num),0,b:js_cache[2] - 1),1) !=# 'switch' ? 0 :
178178
\ &cino !~ ':' || !has('float') ? s:sw() :
179179
\ float2nr(str2float(matchstr(&cino,'.*:\zs[-0-9.]*')) * (&cino =~# '.*:[^,]*s' ? s:sw() : 1))
180180

181181
" most significant, find the indent amount
182182
let isOp = l:line =~# g:javascript_opfirst || pline =~# g:javascript_continuation
183-
if isOp && (num == 0 || cursor(b:js_cache[1],b:js_cache[2]) || s:IsBlock()) ||
183+
if isOp && (num <= 0 || cursor(b:js_cache[1],b:js_cache[2]) || s:IsBlock()) ||
184184
\ s:OneScope(l:lnum,pline,0) =~# '\<\%(for\|each\|if\|let\|no\sb\|w\%(hile\|ith\)\)\>' &&
185185
\ l:line !~ s:line_pre . '{'
186186
return (num > 0 ? indent(num) : -s:sw()) + (s:sw() * 2) + switch_offset

0 commit comments

Comments
 (0)