From 961c528afc7f3a21a8c4b118a2c585dbe670c5c5 Mon Sep 17 00:00:00 2001 From: Billy Su Date: Wed, 22 Jan 2020 17:50:33 +0800 Subject: ex_getln.c: wildmenu add cancel and apply ops --- src/nvim/ex_getln.c | 18 ++++++++++++++++- src/nvim/ex_getln.h | 2 ++ test/functional/ui/wildmode_spec.lua | 38 ++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index 551482dab3..380dc43b50 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -621,6 +621,16 @@ static int command_line_execute(VimState *state, int key) s->c = Ctrl_N; } } + if (compl_match_array || s->did_wild_list) { + if (s->c == Ctrl_E) { + s->res = nextwild(&s->xpc, WILD_CANCEL, WILD_NO_BEEP, + s->firstc != '@'); + } else if (s->c == Ctrl_Y) { + s->res = nextwild(&s->xpc, WILD_APPLY, WILD_NO_BEEP, + s->firstc != '@'); + s->c = Ctrl_E; + } + } // Hitting CR after "emenu Name.": complete submenu if (s->xpc.xp_context == EXPAND_MENUNAMES && p_wmnu @@ -3788,6 +3798,12 @@ ExpandOne ( return NULL; } + if (mode == WILD_CANCEL) { + ss = vim_strsave(orig_save); + } else if (mode == WILD_APPLY) { + ss = vim_strsave(findex == -1 ? orig_save : xp->xp_files[findex]); + } + /* free old names */ if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST) { FreeWild(xp->xp_numfiles, xp->xp_files); @@ -3799,7 +3815,7 @@ ExpandOne ( if (mode == WILD_FREE) /* only release file name */ return NULL; - if (xp->xp_numfiles == -1) { + if (xp->xp_numfiles == -1 && mode != WILD_APPLY && mode != WILD_CANCEL) { xfree(orig_save); orig_save = orig; orig_saved = TRUE; diff --git a/src/nvim/ex_getln.h b/src/nvim/ex_getln.h index 99d5a7786d..84b2b41f30 100644 --- a/src/nvim/ex_getln.h +++ b/src/nvim/ex_getln.h @@ -16,6 +16,8 @@ #define WILD_ALL 6 #define WILD_LONGEST 7 #define WILD_ALL_KEEP 8 +#define WILD_CANCEL 9 +#define WILD_APPLY 10 #define WILD_LIST_NOTFOUND 0x01 #define WILD_HOME_REPLACE 0x02 diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua index f3fa711fb1..d655ab20d3 100644 --- a/test/functional/ui/wildmode_spec.lua +++ b/test/functional/ui/wildmode_spec.lua @@ -16,6 +16,44 @@ describe("'wildmenu'", function() screen:attach() end) + it('C-E to cancel wildmenu completion restore original input', function() + feed(':sign ') + screen:expect([[ + | + ~ | + ~ | + define jump list > | + :sign define^ | + ]]) + feed('') + screen:expect([[ + | + ~ | + ~ | + ~ | + :sign ^ | + ]]) + end) + + it('C-Y to apply selection and end wildmenu completion', function() + feed(':sign ') + screen:expect([[ + | + ~ | + ~ | + define jump list > | + :sign define^ | + ]]) + feed('') + screen:expect([[ + | + ~ | + ~ | + ~ | + :sign jump^ | + ]]) + end) + it(':sign shows wildmenu completions', function() command('set wildmenu wildmode=full') feed(':sign ') -- cgit From dd5d00aaa9af33d62271d989b8f1f709500a570b Mon Sep 17 00:00:00 2001 From: Billy Su Date: Tue, 18 Feb 2020 17:10:29 +0800 Subject: doc: C-Y and C-E in wildmenu completion Add description of C-Y and C-E in wildmenu completion --- runtime/doc/options.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 70af23ee29..9d044406c8 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -6689,6 +6689,9 @@ A jump table for the options with a short description can be found at |Q_op|. While the menu is active these keys have special meanings: - select previous/next match (like CTRL-P/CTRL-N) + - Accet the currenty selected match and stop + completion. + - End completion, back to original typed text. - in filename/menu name completion: move into a subdirectory or submenu. - in menu completion, when the cursor is just after a -- cgit From 4d53bdccc60a4bc39e6ca2c626f4b511881559ef Mon Sep 17 00:00:00 2001 From: Zantox Date: Tue, 24 Mar 2020 22:40:55 +0100 Subject: doc: Fix wildmenu doc inconsistencies and typos Fix typos, capitalization to match block, and remove the angle brackets on the CTRL keys to match other documentation. --- runtime/doc/options.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 9d044406c8..12af911d6d 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -6688,10 +6688,11 @@ A jump table for the options with a short description can be found at |Q_op|. While the menu is active these keys have special meanings: + CTRL-Y - accept the currently selected match and stop + completion. + CTRL-E - end completion, go back to what was there before + selecting a match. - select previous/next match (like CTRL-P/CTRL-N) - - Accet the currenty selected match and stop - completion. - - End completion, back to original typed text. - in filename/menu name completion: move into a subdirectory or submenu. - in menu completion, when the cursor is just after a -- cgit