diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-01-27 00:21:22 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-01-27 00:51:58 +0100 |
commit | 1a3d2dbfe7aadef46b26eac125949a3e1b100194 (patch) | |
tree | 7909cdf506ffab93463a23f6d45a74990d464f70 /src | |
parent | d760e08facda964c04c08d589135cd6b53e16196 (diff) | |
download | rneovim-1a3d2dbfe7aadef46b26eac125949a3e1b100194.tar.gz rneovim-1a3d2dbfe7aadef46b26eac125949a3e1b100194.tar.bz2 rneovim-1a3d2dbfe7aadef46b26eac125949a3e1b100194.zip |
menu_get(): fix query behavior
- Return the menu properties, not only its children.
- If the {path} param is given, return only the first node. The "next"
nodes in the linked-list are irrelevant.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/menu.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/nvim/menu.c b/src/nvim/menu.c index 805952f395..aea297fce2 100644 --- a/src/nvim/menu.c +++ b/src/nvim/menu.c @@ -735,27 +735,31 @@ static dict_T *menu_get_recursive(const vimmenu_T *menu, int modes) /// @return false if could not find path_name bool menu_get(char_u *const path_name, int modes, list_T *list) { - vimmenu_T *menu; - menu = find_menu(root_menu, path_name, modes); + vimmenu_T *menu = find_menu(root_menu, path_name, modes); if (!menu) { return false; } for (; menu != NULL; menu = menu->next) { - dict_T *dict = menu_get_recursive(menu, modes); - if (dict && tv_dict_len(dict) > 0) { - tv_list_append_dict(list, dict); + dict_T *d = menu_get_recursive(menu, modes); + if (d && tv_dict_len(d) > 0) { + tv_list_append_dict(list, d); + } + if (*path_name != NUL) { + // If a (non-empty) path query was given, only the first node in the + // find_menu() result is relevant. Else we want all nodes. + break; } } return true; } -/// Find menu matching required name and modes +/// Find menu matching `name` and `modes`. /// /// @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 -static 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; |