Fix normal-mode repeat affected by visual-mode operator

This commit is contained in:
Junegunn Choi
2013-12-05 13:36:01 +09:00
parent f400e4d8d1
commit 62387b78e0
2 changed files with 24 additions and 1 deletions

View File

@@ -29,6 +29,8 @@ let g:loaded_easy_align_plugin = 1
command! -nargs=* -range -bang EasyAlign <line1>,<line2>call easy_align#align('<bang>' == '!', 0, '', <q-args>) command! -nargs=* -range -bang EasyAlign <line1>,<line2>call easy_align#align('<bang>' == '!', 0, '', <q-args>)
command! -nargs=* -range -bang LiveEasyAlign <line1>,<line2>call easy_align#align('<bang>' == '!', 1, '', <q-args>) command! -nargs=* -range -bang LiveEasyAlign <line1>,<line2>call easy_align#align('<bang>' == '!', 1, '', <q-args>)
let s:last_command = 'EasyAlign'
function! s:generic_easy_align_op(type, vmode, live) function! s:generic_easy_align_op(type, vmode, live)
let sel_save = &selection let sel_save = &selection
let &selection = "inclusive" let &selection = "inclusive"
@@ -49,9 +51,13 @@ function! s:generic_easy_align_op(type, vmode, live)
try try
if get(g:, 'easy_align_need_repeat', 0) if get(g:, 'easy_align_need_repeat', 0)
execute "'<,'>". g:easy_align_last_command execute "'<,'>". s:last_command
else else
'<,'>call easy_align#align('<bang>' == '!', a:live, vmode, '') '<,'>call easy_align#align('<bang>' == '!', a:live, vmode, '')
" Currently visual-mode operator is not repeatable
if !a:vmode
let s:last_command = g:easy_align_last_command
endif
end end
silent! call repeat#set("\<Plug>(EasyAlignRepeat)") silent! call repeat#set("\<Plug>(EasyAlignRepeat)")
finally finally

View File

@@ -1545,6 +1545,23 @@ Expect:
bbb = 3 bbb = 3
aaaa = 4 aaaa = 4
Do (Visual-mode operator is not repeatable and shouldn't affect normal-mode repeat):
\<Space>Aj=
3G
Vj\<Enter>\<Enter>=
7G
.
Expect:
a = 1
bb = 2
ccc = 3
dddd = 4
d = 1
cc = 2
bbb = 3
aaaa = 4
########################################################### ###########################################################
Execute: Execute:
Restore Restore