From 6bc221c28511e3e2cd9b26715ee7f86d82ada552 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Fri, 3 Oct 2014 11:25:51 +0900 Subject: [PATCH] Fix #40: Spurious undo in live interactive mode Problem identified and patch provided by @wilywampa --- autoload/easy_align.vim | 3 ++- test/fixed.vader | 13 +++++++++++++ test/include/teardown.vader | 3 ++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/autoload/easy_align.vim b/autoload/easy_align.vim index dbaa73f..377f0ac 100644 --- a/autoload/easy_align.vim +++ b/autoload/easy_align.vim @@ -640,7 +640,8 @@ function! s:interactive(range, modes, n, d, opts, rules, vis, live, bvis) let output = s:process(a:range, mode, n, d, s:normalize_options(opts), regx, a:rules, a:bvis) let &undolevels = &undolevels " Break undo block call s:update_lines(output.todo) - let undo = 1 + let undo = !empty(output.todo) + let undo = !empty(output.todo) let rdrw = 1 endif if rdrw diff --git a/test/fixed.vader b/test/fixed.vader index 6b45a34..f88f791 100644 --- a/test/fixed.vader +++ b/test/fixed.vader @@ -161,4 +161,17 @@ Expect: d, e, f +Given c (#40 Ignored delimiters in LiveEasyAlign causes spurious undo): + printf("foo = %f\n", foo); + printf("foobar = %f\n", foobar); + +Do: + gUiw + :%LiveEasyAlign\ + =\== + +Expect c: + PRINTF("foo = %f\n", foo); + printf("foobar = %f\n", foobar); + Include: include/teardown.vader diff --git a/test/include/teardown.vader b/test/include/teardown.vader index d5d7930..e34df66 100644 --- a/test/include/teardown.vader +++ b/test/include/teardown.vader @@ -1,3 +1,4 @@ -Execute: +Given: +Execute (Restoring test environment): Restore