Skip to content

Commit 5fb7123

Browse files
leandrolanzierijserv
authored andcommitted
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. Signed-off-by: Jim Huang <[email protected]>
1 parent 121c88e commit 5fb7123

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

menuconfig.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,14 @@ def _leave_menu():
12071207
# Jump to parent menu
12081208
parent = _parent_menu(_cur_menu)
12091209
_shown = _shown_nodes(parent)
1210-
_sel_node_i = _shown.index(_cur_menu)
1210+
1211+
try:
1212+
_sel_node_i = _shown.index(_cur_menu)
1213+
except ValueError:
1214+
# The parent actually does not contain the current menu (e.g., symbol
1215+
# search). So we jump to the first node instead.
1216+
_sel_node_i = 0
1217+
12111218
_cur_menu = parent
12121219

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

0 commit comments

Comments
 (0)