diff --git a/internal/config/data/ns.go b/internal/config/data/ns.go index fb1a515b..0e0e2228 100644 --- a/internal/config/data/ns.go +++ b/internal/config/data/ns.go @@ -12,7 +12,7 @@ import ( const ( // MaxFavoritesNS number # favorite namespaces to keep in the configuration. - MaxFavoritesNS = 10 + MaxFavoritesNS = 9 ) // Namespace tracks active and favorites namespaces. diff --git a/internal/view/browser.go b/internal/view/browser.go index 7f0876d1..d5c9cfdf 100644 --- a/internal/view/browser.go +++ b/internal/view/browser.go @@ -585,13 +585,19 @@ func (b *Browser) namespaceActions(aa *ui.KeyActions) { aa.Add(ui.Key0, ui.NewKeyAction(client.NamespaceAll, b.switchNamespaceCmd, true)) b.namespaces[0] = client.NamespaceAll index := 1 - for _, ns := range b.app.Config.FavNamespaces() { + favNamespaces := b.app.Config.FavNamespaces() + for _, ns := range favNamespaces { if ns == client.NamespaceAll { continue } - aa.Add(ui.NumKeys[index], ui.NewKeyAction(ns, b.switchNamespaceCmd, true)) - b.namespaces[index] = ns - index++ + if numKey, ok := ui.NumKeys[index]; ok { + aa.Add(numKey, ui.NewKeyAction(ns, b.switchNamespaceCmd, true)) + b.namespaces[index] = ns + index++ + } else { + log.Warn().Msgf("No number key available for favorite namespace %s (%d of %d). Skipping...", ns, index, len(favNamespaces)) + break + } } }