Fix dot repeat with count
- Solution: Consider into the char on the cursor position while dot repeat. fix #164
This commit is contained in:
parent
d61f2bdf23
commit
2d2b597ce3
@ -59,6 +59,7 @@ function! EasyMotion#reset()
|
|||||||
\ 'bd_t' : 0,
|
\ 'bd_t' : 0,
|
||||||
\ 'find_bd' : 0,
|
\ 'find_bd' : 0,
|
||||||
\ 'linewise' : 0,
|
\ 'linewise' : 0,
|
||||||
|
\ 'count_dot_repeat' : 0,
|
||||||
\ }
|
\ }
|
||||||
" regexp: -> regular expression
|
" regexp: -> regular expression
|
||||||
" This value is used when multi input find motion. If this values is
|
" This value is used when multi input find motion. If this values is
|
||||||
@ -70,6 +71,8 @@ function! EasyMotion#reset()
|
|||||||
" This value is used to recheck the motion is inclusive or exclusive
|
" This value is used to recheck the motion is inclusive or exclusive
|
||||||
" because 'f' & 't' forward find motion is inclusive, but 'F' & 'T'
|
" because 'f' & 't' forward find motion is inclusive, but 'F' & 'T'
|
||||||
" backward find motion is exclusive
|
" backward find motion is exclusive
|
||||||
|
" count_dot_repeat: -> dot repeat with count
|
||||||
|
" https://github.com/Lokaltog/vim-easymotion/issues/164
|
||||||
let s:current = {
|
let s:current = {
|
||||||
\ 'is_operator' : 0,
|
\ 'is_operator' : 0,
|
||||||
\ 'is_search' : 0,
|
\ 'is_search' : 0,
|
||||||
@ -301,6 +304,7 @@ function! EasyMotion#DotRepeat(visualmode) " {{{
|
|||||||
let s:flag.bd_t = s:dot_repeat.bd_t_flag
|
let s:flag.bd_t = s:dot_repeat.bd_t_flag
|
||||||
let s:current.is_operator = 1
|
let s:current.is_operator = 1
|
||||||
|
|
||||||
|
let s:flag.count_dot_repeat = (i > 0 ? 1 : 0)
|
||||||
silent call s:EasyMotion(re, direction, 0, is_inclusive)
|
silent call s:EasyMotion(re, direction, 0, is_inclusive)
|
||||||
endfor
|
endfor
|
||||||
return s:EasyMotion_is_cancelled
|
return s:EasyMotion_is_cancelled
|
||||||
@ -1189,6 +1193,14 @@ function! s:EasyMotion(regexp, direction, visualmode, is_inclusive) " {{{
|
|||||||
endif
|
endif
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
|
" Handle dot repeat with count
|
||||||
|
if s:flag.count_dot_repeat
|
||||||
|
let cursor_char = EasyMotion#helper#get_char_by_coord(s:current.cursor_position)
|
||||||
|
if cursor_char =~# regexp
|
||||||
|
call add(targets, s:current.cursor_position)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
" Construct match dict {{{
|
" Construct match dict {{{
|
||||||
while 1
|
while 1
|
||||||
" Note: searchpos() has side effect which jump cursor position.
|
" Note: searchpos() has side effect which jump cursor position.
|
||||||
|
@ -33,6 +33,17 @@ function! EasyMotion#helper#mode(flag) "{{{
|
|||||||
return mode(a:flag) == "\<C-v>" ? "C-v" : mode(a:flag)
|
return mode(a:flag) == "\<C-v>" ? "C-v" : mode(a:flag)
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! EasyMotion#helper#get_char_by_coord(coord) "{{{
|
||||||
|
" @param coord: [lnum, col] or [bufnum, lnum, col, off]
|
||||||
|
if len(a:coord) == 4
|
||||||
|
let [line_num, col_num] = [a:coord[1], a:coord[2]]
|
||||||
|
else
|
||||||
|
let [line_num, col_num] = a:coord
|
||||||
|
endif
|
||||||
|
let target_col_regexp = '\%' . (col_num) . 'c.'
|
||||||
|
return matchstr(getline(line_num), target_col_regexp)
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
function! EasyMotion#helper#is_greater_coords(coords1, coords2) "{{{
|
function! EasyMotion#helper#is_greater_coords(coords1, coords2) "{{{
|
||||||
" [line_num, col_num] < [line_num, col_num]
|
" [line_num, col_num] < [line_num, col_num]
|
||||||
"
|
"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user