aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-08-04 14:45:05 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-08-05 06:29:05 +0800
commit69299380ca501558c1d844fc90075cfb7de17a15 (patch)
treedd899325e027c426b7178b99138eafb2c091b121
parent27ce21ac852cb520740210ba68062e981657b6f4 (diff)
downloadrneovim-69299380ca501558c1d844fc90075cfb7de17a15.tar.gz
rneovim-69299380ca501558c1d844fc90075cfb7de17a15.tar.bz2
rneovim-69299380ca501558c1d844fc90075cfb7de17a15.zip
fix(menu): make :menu still print header when there are no menus
-rw-r--r--src/nvim/menu.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/nvim/menu.c b/src/nvim/menu.c
index febb66081a..15e1fbe148 100644
--- a/src/nvim/menu.c
+++ b/src/nvim/menu.c
@@ -810,17 +810,23 @@ static vimmenu_T *find_menu(vimmenu_T *menu, char *name, int modes)
/// Show the mapping associated with a menu item or hierarchy in a sub-menu.
static int show_menus(char *const path_name, int modes)
{
- // First, find the (sub)menu with the given name
- vimmenu_T *menu = find_menu(*get_root_menu(path_name), path_name, modes);
- if (!menu) {
- return FAIL;
+ vimmenu_T *menu = *get_root_menu(path_name);
+ if (menu != NULL) {
+ // First, find the (sub)menu with the given name
+ menu = find_menu(menu, path_name, modes);
+ if (menu == NULL) {
+ return FAIL;
+ }
}
+ // When there are no menus at all, the title still needs to be shown.
// Now we have found the matching menu, and we list the mappings
// Highlight title
msg_puts_title(_("\n--- Menus ---"));
- show_menus_recursive(menu->parent, modes, 0);
+ if (menu != NULL) {
+ show_menus_recursive(menu->parent, modes, 0);
+ }
return OK;
}