switch-account: fix out-of-bounds panic

Fix out-of-bounds panic by updating the focused int variable when
headers change in the switch-account commands.

Fixes: d371c1ac8 ("commands: add switch-account command for composer")
Reported-by: Bence Ferdinandy <bence@ferdinandy.com>
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
This commit is contained in:
Koni Marti 2022-10-17 09:38:05 +02:00 committed by Robin Jarry
parent 49038aa2eb
commit 8ffcd3e5ad
1 changed files with 3 additions and 0 deletions

View File

@ -176,6 +176,9 @@ func (c *Composer) setupFor(acct *AccountView) error {
if focusEditor != nil {
c.focusable = append(c.focusable, focusEditor)
}
if c.focused >= len(c.focusable) {
c.focused = len(c.focusable) - 1
}
// redraw the grid
c.updateGrid()