From 89c486d0851c58d4a42e9efa292a2e76b29eea49 Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Wed, 26 Oct 2022 11:28:53 +0200 Subject: [PATCH] Fix off-by-one in initial pos for menus with no header Menus without a header had their initial position set to the second element by default. This was due to most menus having a header and us calling next_item() unconditionally. Now we first go to the first focusable item and then call next_item() as many times as needed to get to the specified initial_pos. --- clintermission/climenu.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/clintermission/climenu.py b/clintermission/climenu.py index ef3eaf5..4c9495b 100644 --- a/clintermission/climenu.py +++ b/clintermission/climenu.py @@ -336,7 +336,10 @@ class CliMenu: self._searchbar]) # set initial pos - for _ in range(self._initial_pos + 1): + while not self._items[self._pos].focusable: + self._pos += 1 + + for _ in range(self._initial_pos): self.next_item(1) app = Application(layout=Layout(split),