Skip to content

Commit 3249d0e

Browse files
committed
kconfig: Avoid crashing when leaving menu not in parent
This commit adds a catch for an exception that may occur when exiting a menu that was not displayed by the parent menu. This can happen, for example, when searching for the symbol of a named choice.
1 parent 1961ebb commit 3249d0e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tools/kconfig/menuconfig.py

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

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

0 commit comments

Comments
 (0)