From 26412d400fc4fc8ae39f0d928603524b76b9d207 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 edea51a..9787a70 100644 --- a/clintermission/climenu.py +++ b/clintermission/climenu.py @@ -341,7 +341,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),