Skip to content

Commit 4bd734e

Browse files
authored
more accurate do->while (#1062)
1 parent e55c27e commit 4bd734e

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

indent/javascript.vim

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,19 @@ endfunction
256256

257257
function s:DoWhile()
258258
let cpos = searchpos('\m\<','cbW')
259-
if s:SearchLoop('\C[{}]\|\<\%(do\|while\)\>','bW',s:skip_expr)
260-
if s:{s:LookingAt() == '}' && s:GetPair('{','}','bW',s:skip_expr) ?
261-
\ 'Previous' : ''}Token() ==# 'do' && s:IsBlock()
262-
return 1
259+
while s:SearchLoop('\C[{}]\|\<\%(do\|while\)\>','bW',s:skip_expr)
260+
if s:LookingAt() =~ '\a'
261+
if s:Pure('s:IsBlock')
262+
if s:LookingAt() ==# 'd'
263+
return 1
264+
endif
265+
break
266+
endif
267+
elseif s:LookingAt() != '}' || !s:GetPair('{','}','bW',s:skip_expr)
268+
break
263269
endif
264-
call call('cursor',cpos)
265-
endif
270+
endwhile
271+
call call('cursor',cpos)
266272
endfunction
267273

268274
" returns total offset from braceless contexts. 'num' is the lineNr which

0 commit comments

Comments
 (0)