Skip to content

Commit

Permalink
fix infinite loop for argument object not supported by %
Browse files Browse the repository at this point in the history
  • Loading branch information
vanaigr committed Nov 14, 2023
1 parent 642d3a4 commit 5d9cc0c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion autoload/targets/sources/argument.vim
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,14 @@ function! s:findArgBoundary(flags1, flags2, skip, finish, all, separator)

let [tl, rl, rc] = [0, 0, 0]
let [rl, rc] = searchpos(a:all, a:flags1)
let iteration = 0
while 1
if rl == 0
if iteration >= 50000
echohl ErrorMsg
echomsg "ERROR: exceded maximum number of iterations"
echohl None
return [0, 0, targets#util#fail('findArgBoundary 2')]
elseif rl == 0
return [0, 0, targets#util#fail('findArgBoundary 1', a:)]
endif

Expand All @@ -177,11 +183,17 @@ function! s:findArgBoundary(flags1, flags2, skip, finish, all, separator)
endif
break
elseif char =~# a:skip
let [lastB, lastL, lastC, curO] = getpos('.')
silent! keepjumps normal! %
let [_, curL, curC, lastO] = getpos('.')
if curL < lastL || (curL == lastL && curC < lastC) || (curL == lastL && curC == lastC && curO < lastO)
call setpos('.', [lastB, lastL, lastC, lastO])
endif
else
return [0, 0, targets#util#fail('findArgBoundary 2')]
endif
let [rl, rc] = searchpos(a:all, a:flags2)
let iteration += 1
endwhile

return [rl, rc, 0]
Expand Down

0 comments on commit 5d9cc0c

Please sign in to comment.