diff --git a/autoload/matchup/motion.vim b/autoload/matchup/motion.vim index 3688894..0340d0d 100644 --- a/autoload/matchup/motion.vim +++ b/autoload/matchup/motion.vim @@ -324,39 +324,45 @@ function! matchup#motion#jump_inside_prev(visual) abort " {{{1 normal! gv endif - for l:counter in range(l:count + 1) - if l:counter + for l:counter in range(l:count) + let l:delim = matchup#delim#get_current('all', 'open') + if !empty(l:delim) + call matchup#pos#set_cursor(matchup#pos#prev(l:delim)) + endif + + for l:tries in range(2) let l:delim = matchup#delim#get_prev('all', 'open') - else - let l:delim = matchup#delim#get_current('all', 'open') + if empty(l:delim) - let l:delim = matchup#delim#get_prev('all', 'open') + call matchup#pos#set_cursor(l:save_pos) + return endif - endif - if empty(l:delim) - call matchup#pos#set_cursor(l:save_pos) - return - endif - let l:new_pos = [l:delim.lnum, l:delim.cnum] - call matchup#pos#set_cursor(matchup#pos#prev(l:delim)) - let l:new_pos[1] += matchup#delim#end_offset(l:delim) + let l:new_pos = matchup#pos#(l:delim) + let l:new_pos[1] += matchup#delim#end_offset(l:delim) + let l:new_pos = matchup#pos#next(l:new_pos) + + " jump ahead if inside indent + if matchup#util#in_indent(l:new_pos[1], l:new_pos[2]) + let l:new_pos[2] = 1 + strlen(matchstr( + \ getline(l:new_pos[1]), '^\s\+')) + endif + + if matchup#pos#smaller(l:new_pos, l:save_pos) + break + endif + + call matchup#pos#set_cursor(matchup#pos#prev_eol(l:delim)) + endfor endfor call matchup#pos#set_cursor(l:save_pos) - " convert to [~, lnum, cnum, ~] format - let l:new_pos = matchup#pos#next(l:new_pos) - let l:is_oper = !empty(get(s:, 'v_operator', '')) " handle selection option 'exclusive' if l:is_oper && &selection ==# 'exclusive' let l:new_pos = matchup#pos#next_eol(l:new_pos) - " normal! o - " call matchup#pos#set_cursor(matchup#pos#next_eol( - " \ matchup#pos#get_cursor())) - " normal! o endif if !g:matchup_motion_keepjumps diff --git a/doc/matchup.txt b/doc/matchup.txt index 837a232..e0ae14a 100644 --- a/doc/matchup.txt +++ b/doc/matchup.txt @@ -188,6 +188,7 @@ the corresponding default left-hand side will not be mapped. [% |(matchup-[%)| nx motion ]% |(matchup-]%)| nx motion z% |(matchup-z%)| nx motion + (none) |(matchup-Z%)| nx motion a% |(matchup-a%)| x text_obj i% |(matchup-i%)| x text_obj ds% |(matchup-ds%)| n surround