mirror of
https://github.com/neovim/neovim.git
synced 2025-09-21 18:58:18 +00:00
fix ":menu Item.SubItem"
:menu should print sub-menu contents. E.g. this should print the
"File.Save" submenu:
nvim -u NORC
:source $VIMRUNTIME/menu.vim
:menu File.Save
Regressed in dc685387a3
Blocks #8173
menu_get() also was missing some results for some cases.
This commit is contained in:
@@ -754,23 +754,28 @@ bool menu_get(char_u *const path_name, int modes, list_T *list)
|
|||||||
/// @param menu top menu to start looking from
|
/// @param menu top menu to start looking from
|
||||||
/// @param name path towards the menu
|
/// @param name path towards the menu
|
||||||
/// @return menu if \p name is null, found menu or NULL
|
/// @return menu if \p name is null, found menu or NULL
|
||||||
vimmenu_T *
|
static vimmenu_T* find_menu(vimmenu_T *menu, char_u * name, int modes)
|
||||||
find_menu(vimmenu_T *menu, char_u * name, int modes)
|
|
||||||
{
|
{
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
while (*name) {
|
while (*name) {
|
||||||
|
// find the end of one dot-separated name and put a NUL at the dot
|
||||||
p = menu_name_skip(name);
|
p = menu_name_skip(name);
|
||||||
while (menu != NULL) {
|
while (menu != NULL) {
|
||||||
if (menu_name_equal(name, menu)) {
|
if (menu_name_equal(name, menu)) {
|
||||||
/* Found menu */
|
// Found menu
|
||||||
if (*p != NUL && menu->children == NULL) {
|
if (*p != NUL && menu->children == NULL) {
|
||||||
|
if (*p != NUL) {
|
||||||
EMSG(_(e_notsubmenu));
|
EMSG(_(e_notsubmenu));
|
||||||
return NULL;
|
return NULL;
|
||||||
} else if ((menu->modes & modes) == 0x0) {
|
} else if ((menu->modes & modes) == 0x0) {
|
||||||
EMSG(_(e_othermode));
|
EMSG(_(e_othermode));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (*p == NUL) { // found a full match
|
||||||
|
return menu;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
menu = menu->next;
|
menu = menu->next;
|
||||||
@@ -780,6 +785,7 @@ find_menu(vimmenu_T *menu, char_u * name, int modes)
|
|||||||
EMSG2(_(e_nomenu), name);
|
EMSG2(_(e_nomenu), name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
// Found a match, search the sub-menu.
|
||||||
name = p;
|
name = p;
|
||||||
menu = menu->children;
|
menu = menu->children;
|
||||||
}
|
}
|
||||||
@@ -1235,7 +1241,7 @@ static char_u *popup_mode_name(char_u *name, int idx)
|
|||||||
///
|
///
|
||||||
/// @return a pointer to allocated memory.
|
/// @return a pointer to allocated memory.
|
||||||
static char_u *menu_text(const char_u *str, int *mnemonic, char_u **actext)
|
static char_u *menu_text(const char_u *str, int *mnemonic, char_u **actext)
|
||||||
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_WARN_UNUSED_RESULT
|
FUNC_ATTR_NONNULL_RET FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
FUNC_ATTR_NONNULL_ARG(1)
|
FUNC_ATTR_NONNULL_ARG(1)
|
||||||
{
|
{
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
@@ -362,6 +362,9 @@ describe('menu_get', function()
|
|||||||
it('matching path and modes', function()
|
it('matching path and modes', function()
|
||||||
local m = funcs.menu_get("Test","i")
|
local m = funcs.menu_get("Test","i")
|
||||||
local expected = {
|
local expected = {
|
||||||
|
{
|
||||||
|
shortcut = "T",
|
||||||
|
submenus = {
|
||||||
{
|
{
|
||||||
mappings = {
|
mappings = {
|
||||||
i = {
|
i = {
|
||||||
@@ -370,7 +373,14 @@ describe('menu_get', function()
|
|||||||
enabled = 1,
|
enabled = 1,
|
||||||
rhs = "insert",
|
rhs = "insert",
|
||||||
silent = 0
|
silent = 0
|
||||||
}
|
},
|
||||||
|
},
|
||||||
|
priority = 500,
|
||||||
|
name = "Test",
|
||||||
|
hidden = 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
},
|
||||||
},
|
},
|
||||||
priority = 500,
|
priority = 500,
|
||||||
name = "Test",
|
name = "Test",
|
||||||
|
Reference in New Issue
Block a user