From f9b429c69633ee7016186d4e4990b664e42d42e7 Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Wed, 26 Oct 2022 12:26:36 +0200 Subject: [PATCH] Return with "no success" when no options are given If the user gave us no options then we used to just raise a ValueError (due to initial_pos being out of range). In most - if not all - cases it would be more favorable to act the same way as if the selection has been aborted, so that's what we're doing now. --- clintermission/climenu.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/clintermission/climenu.py b/clintermission/climenu.py index ef3eaf5..edea51a 100644 --- a/clintermission/climenu.py +++ b/clintermission/climenu.py @@ -272,6 +272,10 @@ class CliMenu: event.app.exit() def _run(self): + if self._item_num == 0: + self._success = False + return + self._preflight() class MenuColorizer(Processor): @@ -284,6 +288,7 @@ class CliMenu: @self._kb.add('q', filter=~is_searching) @self._kb.add('c-c') def quit(event): + self._success = False event.app.exit() @self._kb.add('down', filter=~is_searching)