From 74c00bb717238100c924263d636f4d8d4696e1b9 Mon Sep 17 00:00:00 2001 From: "Andy K. Massimino" Date: Wed, 8 Nov 2017 08:52:55 -0500 Subject: [PATCH] Fix count for %, g%; change override N% limit to 6 --- autoload/matchup.vim | 2 +- autoload/matchup/motion.vim | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/autoload/matchup.vim b/autoload/matchup.vim index 001f1c5..3f81901 100644 --- a/autoload/matchup.vim +++ b/autoload/matchup.vim @@ -26,7 +26,7 @@ function! s:init_options() call s:init_option('matchup_motion_enabled', 1) call s:init_option('matchup_motion_cursor_end', 1) - call s:init_option('matchup_motion_override_Npercent', 0) + call s:init_option('matchup_motion_override_Npercent', 6) call s:init_option('matchup_text_obj_enabled', 1) call s:init_option('matchup_text_obj_linewise_operators', ['d', 'y']) diff --git a/autoload/matchup/motion.vim b/autoload/matchup/motion.vim index 2d96c8f..ed11b1a 100644 --- a/autoload/matchup/motion.vim +++ b/autoload/matchup/motion.vim @@ -35,13 +35,15 @@ function! matchup#motion#init_module() " {{{1 \ :call matchup#motion#find_matching_pair(1, 1) xmap (matchup-%) (matchup-%) onoremap (matchup-%) - \ :call oper("normal \(v)\(matchup-%)") + \ :call oper("normal \(v)" + \ . (v:count > 0 ? v:count : '') . "\(matchup-%)") xnoremap (matchup-g%) \ :call matchup#motion#find_matching_pair(1, 0) xmap (matchup-g%) (matchup-g%) onoremap (matchup-g%) - \ :call oper("normal \(v)\(matchup-g%)") + \ :call oper("normal \(v)" + \ . (v:count > 0 ? v:count : '') . "\(matchup-g%)") " ]% and [% nnoremap (matchup-]%) @@ -83,15 +85,17 @@ endfunction " }}}1 function! matchup#motion#find_matching_pair(visual, down) " {{{1 - if v:count && a:down && !g:matchup_motion_override_Npercent - exe 'normal!' v:count.'%' - return - endif + let [l:count, l:count1] = [v:count, v:count1] if a:visual normal! gv endif + if a:down && l:count > g:matchup_motion_override_Npercent + exe 'normal!' l:count.'%' + return + endif + let [l:start_lnum, l:start_cnum] = matchup#pos#get_cursor()[1:2] " disable the timeout @@ -106,7 +110,7 @@ function! matchup#motion#find_matching_pair(visual, down) " {{{1 endif " loop count number of times - for l:dummy in range(v:count1) + for l:dummy in range(l:count1) let l:matches = matchup#delim#get_matching(l:delim) if !len(l:matches) | return | endif let l:delim = get(l:delim.links, a:down ? 'next' : 'prev', {})