diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-03-28 01:45:00 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-01-27 00:51:58 +0100 |
commit | 827ed144fb4cfafd2727f55e6b25e07c96962138 (patch) | |
tree | 9fe1a9a6ad2c21f5c532511cb341ba31ac068999 /src | |
parent | d63b534f313326c79c7b9feaf51ca0d798dd65db (diff) | |
download | rneovim-827ed144fb4cfafd2727f55e6b25e07c96962138.tar.gz rneovim-827ed144fb4cfafd2727f55e6b25e07c96962138.tar.bz2 rneovim-827ed144fb4cfafd2727f55e6b25e07c96962138.zip |
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 dc685387a3d6
Blocks #8173
menu_get() also was missing some results for some cases.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/menu.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/nvim/menu.c b/src/nvim/menu.c index 074feb9906..0183f1d276 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -754,22 +754,27 @@ bool menu_get(char_u *const path_name, int modes, list_T *list) /// @param menu top menu to start looking from /// @param name path towards the menu /// @return menu if \p name is null, found menu or NULL -vimmenu_T * -find_menu(vimmenu_T *menu, char_u * name, int modes) +static vimmenu_T* find_menu(vimmenu_T *menu, char_u * name, int modes) { char_u *p; while (*name) { + // find the end of one dot-separated name and put a NUL at the dot p = menu_name_skip(name); while (menu != NULL) { if (menu_name_equal(name, menu)) { - /* Found menu */ + // Found menu if (*p != NUL && menu->children == NULL) { - EMSG(_(e_notsubmenu)); - return NULL; - } else if ((menu->modes & modes) == 0x0) { - EMSG(_(e_othermode)); - return NULL; + if (*p != NUL) { + EMSG(_(e_notsubmenu)); + return NULL; + } else if ((menu->modes & modes) == 0x0) { + EMSG(_(e_othermode)); + return NULL; + } + } + if (*p == NUL) { // found a full match + return menu; } break; } @@ -780,6 +785,7 @@ find_menu(vimmenu_T *menu, char_u * name, int modes) EMSG2(_(e_nomenu), name); return NULL; } + // Found a match, search the sub-menu. name = p; menu = menu->children; } @@ -1235,7 +1241,7 @@ static char_u *popup_mode_name(char_u *name, int idx) /// /// @return a pointer to allocated memory. 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) { char_u *p; |