From a76cfdb8aebfa0b41f057727249362a755c5174b Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Fri, 25 Oct 2013 02:11:43 +0900 Subject: [PATCH] Make user confirm regular expression on live interactive mode --- README.md | 6 +++--- autoload/easy_align.vim | 10 +++++----- doc/easy_align.txt | 8 ++++---- test/interactive.vader | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 9bf2815..656ceae 100644 --- a/README.md +++ b/README.md @@ -183,9 +183,9 @@ in addition to the one for `:EasyAlign` command. vnoremap :LiveEasyAlign ``` -In live interactive mode, you have to type in the same delimiter (or `CTRL-X` on -regular expression) again to finalize the alignment. This allows you to preview -the result of the alignment and freely change the delimiter using backspace key +In live interactive mode, you have to type in the same delimiter or regular +expression again to finalize the alignment. This allows you to preview the +result of the alignment and freely change the delimiter using backspace key without leaving the interactive mode. ### Using `EasyAlign` in command line diff --git a/autoload/easy_align.vim b/autoload/easy_align.vim index 61b66a0..067b605 100644 --- a/autoload/easy_align.vim +++ b/autoload/easy_align.vim @@ -690,16 +690,16 @@ function! s:interactive(range, modes, n, d, opts, rules, vis, live) silent! call remove(opts, 'm') endif elseif ch == "\" || ch == "\" - if a:live && regx && !empty(d) - break - endif + let pd = regx ? d : '' let prompt = 'Regular expression: ' - let ch = s:input(prompt, '', a:vis) + let ch = s:input(prompt, pd, a:vis) if !empty(ch) && s:valid_regexp(ch) let regx = 1 let d = ch - if !a:live | break | endif + if !a:live || pd == d + break + endif else let warn = 'Invalid regular expression: '.ch endif diff --git a/doc/easy_align.txt b/doc/easy_align.txt index e8cc732..898ba0e 100644 --- a/doc/easy_align.txt +++ b/doc/easy_align.txt @@ -121,10 +121,10 @@ following mapping in addition to the one for `:EasyAlign` command. vnoremap :LiveEasyAlign -In live interactive mode, you have to type in the same delimiter (or -`CTRL-X` on regular expression) again to finalize the alignment. This -allows you to preview the result of the alignment and freely change the -delimiter using backspace key without leaving the interactive mode. +In live interactive mode, you have to type in the same delimiter or +regular expression again to finalize the alignment. This allows you to +preview the result of the alignment and freely change the delimiter using +backspace key without leaving the interactive mode. Left/right/center mode switch in interactive mode diff --git a/test/interactive.vader b/test/interactive.vader index 76d666f..a917184 100644 --- a/test/interactive.vader +++ b/test/interactive.vader @@ -508,7 +508,7 @@ Do (live interactive mode!): \\ \|\ \ - \ + \\ Expect: [|] Option[|]Type [|]Default[|]Description [|