mirror of
https://github.com/neovim/neovim.git
synced 2025-10-06 18:06:30 +00:00
Merge pull request #11746 from Billy4195/add_wildmenu_key
[RFC] Wildmenu support C-E and C-Y as popupmenu
This commit is contained in:
@@ -6701,6 +6701,10 @@ 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:
|
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.
|
||||||
<Left> <Right> - select previous/next match (like CTRL-P/CTRL-N)
|
<Left> <Right> - select previous/next match (like CTRL-P/CTRL-N)
|
||||||
<Down> - in filename/menu name completion: move into a
|
<Down> - in filename/menu name completion: move into a
|
||||||
subdirectory or submenu.
|
subdirectory or submenu.
|
||||||
|
@@ -621,6 +621,16 @@ static int command_line_execute(VimState *state, int key)
|
|||||||
s->c = Ctrl_N;
|
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
|
// Hitting CR after "emenu Name.": complete submenu
|
||||||
if (s->xpc.xp_context == EXPAND_MENUNAMES && p_wmnu
|
if (s->xpc.xp_context == EXPAND_MENUNAMES && p_wmnu
|
||||||
@@ -3790,6 +3800,12 @@ ExpandOne (
|
|||||||
return NULL;
|
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 */
|
/* free old names */
|
||||||
if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST) {
|
if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST) {
|
||||||
FreeWild(xp->xp_numfiles, xp->xp_files);
|
FreeWild(xp->xp_numfiles, xp->xp_files);
|
||||||
@@ -3801,7 +3817,7 @@ ExpandOne (
|
|||||||
if (mode == WILD_FREE) /* only release file name */
|
if (mode == WILD_FREE) /* only release file name */
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (xp->xp_numfiles == -1) {
|
if (xp->xp_numfiles == -1 && mode != WILD_APPLY && mode != WILD_CANCEL) {
|
||||||
xfree(orig_save);
|
xfree(orig_save);
|
||||||
orig_save = orig;
|
orig_save = orig;
|
||||||
orig_saved = TRUE;
|
orig_saved = TRUE;
|
||||||
|
@@ -16,6 +16,8 @@
|
|||||||
#define WILD_ALL 6
|
#define WILD_ALL 6
|
||||||
#define WILD_LONGEST 7
|
#define WILD_LONGEST 7
|
||||||
#define WILD_ALL_KEEP 8
|
#define WILD_ALL_KEEP 8
|
||||||
|
#define WILD_CANCEL 9
|
||||||
|
#define WILD_APPLY 10
|
||||||
|
|
||||||
#define WILD_LIST_NOTFOUND 0x01
|
#define WILD_LIST_NOTFOUND 0x01
|
||||||
#define WILD_HOME_REPLACE 0x02
|
#define WILD_HOME_REPLACE 0x02
|
||||||
|
@@ -16,6 +16,44 @@ describe("'wildmenu'", function()
|
|||||||
screen:attach()
|
screen:attach()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('C-E to cancel wildmenu completion restore original input', function()
|
||||||
|
feed(':sign <tab>')
|
||||||
|
screen:expect([[
|
||||||
|
|
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
define jump list > |
|
||||||
|
:sign define^ |
|
||||||
|
]])
|
||||||
|
feed('<C-E>')
|
||||||
|
screen:expect([[
|
||||||
|
|
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
:sign ^ |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('C-Y to apply selection and end wildmenu completion', function()
|
||||||
|
feed(':sign <tab>')
|
||||||
|
screen:expect([[
|
||||||
|
|
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
define jump list > |
|
||||||
|
:sign define^ |
|
||||||
|
]])
|
||||||
|
feed('<tab><C-Y>')
|
||||||
|
screen:expect([[
|
||||||
|
|
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
:sign jump^ |
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
it(':sign <tab> shows wildmenu completions', function()
|
it(':sign <tab> shows wildmenu completions', function()
|
||||||
command('set wildmenu wildmode=full')
|
command('set wildmenu wildmode=full')
|
||||||
feed(':sign <tab>')
|
feed(':sign <tab>')
|
||||||
|
Reference in New Issue
Block a user