mirror of
https://github.com/junegunn/vim-easy-align.git
synced 2025-11-17 14:23:42 -05:00
Preserve last selection when using <Plug>(EasyAlign)
This commit is contained in:
@@ -80,25 +80,20 @@ function! s:generic_easy_align_op(type, vmode, live)
|
||||
|
||||
if a:vmode
|
||||
let vmode = a:type
|
||||
let [l1, l2] = ["'<", "'>"]
|
||||
call s:remember_visual(vmode)
|
||||
else
|
||||
let tail = "\<C-c>"
|
||||
if a:type == 'line'
|
||||
silent execute "normal! '[V']".tail
|
||||
elseif a:type == 'block'
|
||||
silent execute "normal! `[\<C-V>`]".tail
|
||||
else
|
||||
silent execute "normal! `[v`]".tail
|
||||
endif
|
||||
let vmode = ''
|
||||
let [l1, l2] = [line("'["), line("']")]
|
||||
unlet! s:last_visual
|
||||
endif
|
||||
|
||||
try
|
||||
let range = l1.','.l2
|
||||
if get(g:, 'easy_align_need_repeat', 0)
|
||||
execute "'<,'>". g:easy_align_last_command
|
||||
execute range . g:easy_align_last_command
|
||||
else
|
||||
'<,'>call easy_align#align('<bang>' == '!', a:live, vmode, '')
|
||||
execute range . "call easy_align#align('<bang>' == '!', a:live, vmode, '')"
|
||||
end
|
||||
call s:set_repeat()
|
||||
finally
|
||||
|
||||
@@ -139,4 +139,26 @@ Expect:
|
||||
## n2gv = {}
|
||||
# n2vt = {}
|
||||
|
||||
Given (Some text):
|
||||
a,b,c
|
||||
|
||||
d,e,f
|
||||
|
||||
Do (Select 1st line, align 3rd line):
|
||||
- First line
|
||||
V\<esc>
|
||||
- Last line
|
||||
G
|
||||
- Align
|
||||
\<space>Aip*,
|
||||
- Previous selection
|
||||
gv
|
||||
- Upcase
|
||||
U
|
||||
|
||||
Expect:
|
||||
A,B,C
|
||||
|
||||
d, e, f
|
||||
|
||||
Include: include/teardown.vader
|
||||
|
||||
Reference in New Issue
Block a user