From 0380400353870974eef82c5ffccd2efb39928370 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Tue, 21 Oct 2025 15:41:12 +0200 Subject: menuconfig: check if current menu is visible in parent when leaving This handles a case of leaving a menu which is not shown by the parent menu. This might occur, for instance, when searching for the symbol of a named choice, which is extended by an invisible symbol somewhere else. --- menuconfig.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/menuconfig.py b/menuconfig.py index a0ab004..21b5f54 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -1202,7 +1202,15 @@ def _leave_menu(): # Jump to parent menu parent = _parent_menu(_cur_menu) _shown = _shown_nodes(parent) - _sel_node_i = _shown.index(_cur_menu) + + if _cur_menu in _shown: + _sel_node_i = _shown.index(_cur_menu) + else: + # The current menu is not visible in the parent menu. This can happen + # when a choice with an associated symbol is extended somewhere + # else by an invisible one. In this case, point to node at index 0. + _sel_node_i = 0 + _cur_menu = parent # Try to make the menu entry appear on the same row on the screen as it did -- cgit v1.2.3