From 1cd724dc239c3a0f7a12e0fac85945cc3dbe07b0 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sat, 3 Jun 2017 22:09:48 +0900 Subject: [PATCH] Fix invalid detection of blockwise visual mode Close #105 --- autoload/easy_align.vim | 6 ++++-- plugin/easy_align.vim | 6 +++--- test/fixed.vader | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/autoload/easy_align.vim b/autoload/easy_align.vim index f759e02..795ea31 100644 --- a/autoload/easy_align.vim +++ b/autoload/easy_align.vim @@ -1088,10 +1088,12 @@ endfunction function! s:align(bang, live, visualmode, first_line, last_line, expr) " 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 bvis = vis && visualmode() == "\" - " Visual-mode explicitly given + elseif empty(a:visualmode) + let vis = 0 + let bvis = 0 else let vis = 1 let bvis = a:visualmode == "\" diff --git a/plugin/easy_align.vim b/plugin/easy_align.vim index dc5092e..c71af4e 100644 --- a/plugin/easy_align.vim +++ b/plugin/easy_align.vim @@ -26,8 +26,8 @@ if exists("g:loaded_easy_align_plugin") endif let g:loaded_easy_align_plugin = 1 -command! -nargs=* -range -bang EasyAlign ,call easy_align#align('' == '!', 0, '', ) -command! -nargs=* -range -bang LiveEasyAlign ,call easy_align#align('' == '!', 1, '', ) +command! -nargs=* -range -bang EasyAlign ,call easy_align#align(0, 0, 'command', ) +command! -nargs=* -range -bang LiveEasyAlign ,call easy_align#align(0, 1, 'command', ) 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) execute range . g:easy_align_last_command else - execute range . "call easy_align#align('' == '!', a:live, vmode, '')" + execute range . "call easy_align#align(0, a:live, vmode, '')" end call s:set_repeat() finally diff --git a/test/fixed.vader b/test/fixed.vader index ebba40f..ccfad3b 100644 --- a/test/fixed.vader +++ b/test/fixed.vader @@ -247,3 +247,17 @@ Expect: servaddr.sin_port = htons(SERV_PORT); 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): + \jj\ + \Aip= + +Expect: + hello = world bye all + hello world = bye all + hello world = foo all