Skip to content

Commit 7e4048c

Browse files
menuconfig: avoid crashing when leaving menu not in parent
This adds a catch to an exception that might occur when 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.
1 parent 061e71f commit 7e4048c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

menuconfig.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,14 @@ def _leave_menu():
12021202
# Jump to parent menu
12031203
parent = _parent_menu(_cur_menu)
12041204
_shown = _shown_nodes(parent)
1205-
_sel_node_i = _shown.index(_cur_menu)
1205+
1206+
try:
1207+
_sel_node_i = _shown.index(_cur_menu)
1208+
except ValueError:
1209+
# The parent actually does not contain the current menu (e.g., symbol
1210+
# search). So we jump to the first node instead.
1211+
_sel_node_i = 0
1212+
12061213
_cur_menu = parent
12071214

12081215
# Try to make the menu entry appear on the same row on the screen as it did

0 commit comments

Comments
 (0)