From 9da3c856e50f433ca830aebc586055982cbf72f5 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Fri, 22 May 2020 14:43:49 +0200 Subject: [PATCH] menuconfig: Avoid crashing when leaving a menu not shown in parent This adds a catch to an exception that might occur when leaving a menu which is not shown by the parent menu. For an example of this refer to issue #93. --- menuconfig.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/menuconfig.py b/menuconfig.py index 7e765d36..61097578 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -1202,7 +1202,12 @@ def _leave_menu(): # Jump to parent menu parent = _parent_menu(_cur_menu) _shown = _shown_nodes(parent) - _sel_node_i = _shown.index(_cur_menu) + + try: + _sel_node_i = _shown.index(_cur_menu) + except ValueError: + _sel_node_i = 0 + _cur_menu = parent # Try to make the menu entry appear on the same row on the screen as it did