Fix dot repeat motion use previous motion info

Problem: Previous motion info is updated by other motion too.
Solution: Store 'dot' previous motion and use it
This commit is contained in:
haya14busa 2014-01-19 21:12:17 +09:00
parent 7faff893e2
commit 9e8ea88683

View File

@ -14,6 +14,7 @@ set cpo&vim
function! EasyMotion#init()
" Init Migemo Dictionary
let s:previous = {}
let s:dot_repeat = {}
let s:migemo_dicts = {}
call EasyMotion#reset()
" Anywhere regular expression: {{{
@ -313,16 +314,17 @@ function! EasyMotion#Repeat(visualmode) " {{{
endfunction " }}}
function! EasyMotion#DotRepeat(visualmode) " {{{
" Repeat previous motion with previous targets
if s:previous ==# {}
if s:dot_repeat ==# {}
call s:Message("Previous motion doesn't exist")
return
endif
let re = s:previous.regexp
let direction = s:previous.direction
let is_exclusive = s:previous.is_exclusive
let re = s:dot_repeat.regexp
let direction = s:dot_repeat.direction
let is_exclusive = s:dot_repeat.is_exclusive
let s:flag.within_line = s:dot_repeat.line_flag
let s:current.is_operator = 1
let s:flag.within_line = s:previous.line_flag
for cnt in range(v:count1)
let s:flag.dot_repeat = 1 " s:EasyMotion() always call reset
silent call s:EasyMotion(re, direction, 0, is_exclusive)
@ -1284,18 +1286,18 @@ function! s:EasyMotion(regexp, direction, visualmode, is_exclusive, ...) " {{{
" support dot repeat {{{
" Use visual mode to emulate dot repeat
normal! v
if s:previous.is_exclusive == 0
if s:previous.direction == 0 "Forward
if s:dot_repeat.is_exclusive == 0
if s:dot_repeat.direction == 0 "Forward
let coords[1] -= 1
elseif s:previous.direction == 1 "Backward
elseif s:dot_repeat.direction == 1 "Backward
" Shift visual selection to left by making cursor one key
" left.
normal! hoh
endif
endif
keepjumps call cursor(coords[0], coords[1])
let cmd = s:previous.operator
if s:previous.operator ==# 'c'
let cmd = s:dot_repeat.operator
if s:dot_repeat.operator ==# 'c'
let cmd .= getreg('.')
endif
@ -1320,11 +1322,18 @@ function! s:EasyMotion(regexp, direction, visualmode, is_exclusive, ...) " {{{
endif
" Set tpope/vim-repeat
" Set tpope/vim-repeat {{{
if s:current.is_operator == 1 &&
\ !(v:operator ==# 'y' && match(&cpo, 'y') == -1)
" Store previous info for dot repeat {{{
let s:dot_repeat.regexp = a:regexp
let s:dot_repeat.direction = a:direction
let s:dot_repeat.line_flag = s:flag.within_line == 1 ? 1 : 0
let s:dot_repeat.is_exclusive = a:is_exclusive
let s:dot_repeat.operator = v:operator
"}}}
silent! call repeat#set("\<Plug>(easymotion-dotrepeat)")
endif
endif "}}}
call s:Message('Jumping to [' . coords[0] . ', ' . coords[1] . ']')
let s:EasyMotion_cancelled = 0