Fix invalid detection of blockwise visual mode

Close #105
This commit is contained in:
Junegunn Choi
2017-06-03 22:09:48 +09:00
parent 14c693dfe5
commit 1cd724dc23
3 changed files with 21 additions and 5 deletions

View File

@@ -1088,10 +1088,12 @@ endfunction
function! s:align(bang, live, visualmode, first_line, last_line, expr) function! s:align(bang, live, visualmode, first_line, last_line, expr)
" Heuristically determine if the user was in visual mode " Heuristically determine if the user was in visual mode
if empty(a:visualmode) if a:visualmode == 'command'
let vis = a:first_line == line("'<") && a:last_line == line("'>") let vis = a:first_line == line("'<") && a:last_line == line("'>")
let bvis = vis && visualmode() == "\<C-V>" let bvis = vis && visualmode() == "\<C-V>"
" Visual-mode explicitly given elseif empty(a:visualmode)
let vis = 0
let bvis = 0
else else
let vis = 1 let vis = 1
let bvis = a:visualmode == "\<C-V>" let bvis = a:visualmode == "\<C-V>"

View File

@@ -26,8 +26,8 @@ if exists("g:loaded_easy_align_plugin")
endif endif
let g:loaded_easy_align_plugin = 1 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, 0, 'command', <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>0, 1, 'command', <q-args>)
let s:last_command = 'EasyAlign' let s:last_command = 'EasyAlign'
@@ -99,7 +99,7 @@ function! s:generic_easy_align_op(type, vmode, live)
if get(g:, 'easy_align_need_repeat', 0) if get(g:, 'easy_align_need_repeat', 0)
execute range . g:easy_align_last_command execute range . g:easy_align_last_command
else else
execute range . "call easy_align#align('<bang>' == '!', a:live, vmode, '')" execute range . "call easy_align#align(0, a:live, vmode, '')"
end end
call s:set_repeat() call s:set_repeat()
finally finally

View File

@@ -247,3 +247,17 @@ Expect:
servaddr.sin_port = htons(SERV_PORT); servaddr.sin_port = htons(SERV_PORT);
Include: include/teardown.vader Include: include/teardown.vader
Given:
hello = world bye all
hello world = bye all
hello world = foo all
Do (#105: Incorrectly detection of blockwise visual mode):
\<c-v>jj\<esc>
\<Space>Aip=
Expect:
hello = world bye all
hello world = bye all
hello world = foo all