From cc064acf0f43c978ad378b20ebe869f5373651a1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 11 Jun 2020 15:36:54 +1000 Subject: UI: exclude context menus from menu search This causes the search result to be less predictable as well as including menu items multiple times. --- .../interface/interface_template_search_menu.c | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'source/blender/editors/interface') diff --git a/source/blender/editors/interface/interface_template_search_menu.c b/source/blender/editors/interface/interface_template_search_menu.c index 2c6b09168f4..8c673e4d5b5 100644 --- a/source/blender/editors/interface/interface_template_search_menu.c +++ b/source/blender/editors/interface/interface_template_search_menu.c @@ -469,6 +469,34 @@ static struct MenuSearch_Data *menu_items_from_ui_create( } } + { + /* Exclude context menus because: + * - The menu items are available elsewhere (and will show up multiple times). + * - Menu items depend on exact context, making search results unpredictable + * (exact number of items selected for example). See design doc T74158. + * There is one exception, + * as the outliner only exposes functionality via the context menu. */ + GHashIterator iter; + + for (WM_menutype_iter(&iter); (!BLI_ghashIterator_done(&iter)); + (BLI_ghashIterator_step(&iter))) { + MenuType *mt = BLI_ghashIterator_getValue(&iter); + if (BLI_str_endswith(mt->idname, "_context_menu")) { + BLI_gset_add(menu_tagged, mt); + } + } + const char *idname_array[] = { + /* Add back some context menus. */ + "OUTLINER_MT_context_menu", + }; + for (int i = 0; i < ARRAY_SIZE(idname_array); i++) { + MenuType *mt = WM_menutype_find(idname_array[i], false); + if (mt != NULL) { + BLI_gset_remove(menu_tagged, mt, NULL); + } + } + } + /* Collect contexts, one for each 'ui_type'. */ struct MenuSearch_Context *wm_contexts = NULL; -- cgit v1.2.3