mirror of
https://github.com/chenasraf/vim-matchup.git
synced 2026-05-17 17:38:01 +00:00
Fix matchup-Z% motion, fix #368
This commit is contained in:
@@ -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
|
||||
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')
|
||||
endif
|
||||
endif
|
||||
if empty(l:delim)
|
||||
call matchup#pos#set_cursor(l:save_pos)
|
||||
return
|
||||
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
|
||||
|
||||
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)
|
||||
for l:tries in range(2)
|
||||
let l:delim = matchup#delim#get_prev('all', 'open')
|
||||
|
||||
if empty(l:delim)
|
||||
call matchup#pos#set_cursor(l:save_pos)
|
||||
return
|
||||
endif
|
||||
|
||||
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
|
||||
|
||||
@@ -188,6 +188,7 @@ the corresponding default left-hand side will not be mapped.
|
||||
[% |<plug>(matchup-[%)| nx motion
|
||||
]% |<plug>(matchup-]%)| nx motion
|
||||
z% |<plug>(matchup-z%)| nx motion
|
||||
(none) |<plug>(matchup-Z%)| nx motion
|
||||
a% |<plug>(matchup-a%)| x text_obj
|
||||
i% |<plug>(matchup-i%)| x text_obj
|
||||
ds% |<plug>(matchup-ds%)| n surround
|
||||
|
||||
Reference in New Issue
Block a user