Skip to content

Commit

Permalink
Make [count]% work as expected
Browse files Browse the repository at this point in the history
fixes #24
  • Loading branch information
chrisbra committed Dec 22, 2020
1 parent 2db9c04 commit 803f429
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions autoload/matchit.vim
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ endfunction

function matchit#Match_wrapper(word, forward, mode) range
let restore_options = s:RestoreOptions()
" In s:CleanUp(), we may need to check whether the cursor moved forward.
let startpos = [line("."), col(".")]
" if a count has been applied, use the default [count]% mode (see :h N%)
if v:count
exe "normal! " . v:count . "%"
return s:CleanUp(restore_options, a:mode, startpos)
end
if a:mode =~# "v" && mode(1) =~# 'ni'
exe "norm! gv"
elseif a:mode == "o" && mode(1) !~# '[vV]'
Expand All @@ -51,13 +58,7 @@ function matchit#Match_wrapper(word, forward, mode) range
elseif a:mode == "v"
execute "normal! gv\<Esc>"
endif
" In s:CleanUp(), we may need to check whether the cursor moved forward.
let startpos = [line("."), col(".")]
" Use default behavior if called with a count.
if v:count
exe "normal! " . v:count . "%"
return s:CleanUp(restore_options, a:mode, startpos)
end

" First step: if not already done, set the script variables
" s:do_BR flag for whether there are backrefs
Expand Down

0 comments on commit 803f429

Please sign in to comment.