Skip to content

Commit 99d47ab

Browse files
authored
Fix "Mark Range": reduce maximum namespaces in favorites, fix shadowing of ctrl+space (#2927)
* fix: avoid creating a ctrl+space key when index out of range * fix: reduce maximum favorite namespaces to 9, making space for "all" * fix: correct index incrementation * refactor: remove usage of NumKeys * feat: check for favorite namespace index in NumKeys * feat: break when out of number keys, increment index when slot found
1 parent 59918d0 commit 99d47ab

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

internal/config/data/ns.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
const (
1414
// MaxFavoritesNS number # favorite namespaces to keep in the configuration.
15-
MaxFavoritesNS = 10
15+
MaxFavoritesNS = 9
1616
)
1717

1818
// Namespace tracks active and favorites namespaces.

internal/view/browser.go

+10-4
Original file line numberDiff line numberDiff line change
@@ -585,13 +585,19 @@ func (b *Browser) namespaceActions(aa *ui.KeyActions) {
585585
aa.Add(ui.Key0, ui.NewKeyAction(client.NamespaceAll, b.switchNamespaceCmd, true))
586586
b.namespaces[0] = client.NamespaceAll
587587
index := 1
588-
for _, ns := range b.app.Config.FavNamespaces() {
588+
favNamespaces := b.app.Config.FavNamespaces()
589+
for _, ns := range favNamespaces {
589590
if ns == client.NamespaceAll {
590591
continue
591592
}
592-
aa.Add(ui.NumKeys[index], ui.NewKeyAction(ns, b.switchNamespaceCmd, true))
593-
b.namespaces[index] = ns
594-
index++
593+
if numKey, ok := ui.NumKeys[index]; ok {
594+
aa.Add(numKey, ui.NewKeyAction(ns, b.switchNamespaceCmd, true))
595+
b.namespaces[index] = ns
596+
index++
597+
} else {
598+
log.Warn().Msgf("No number key available for favorite namespace %s (%d of %d). Skipping...", ns, index, len(favNamespaces))
599+
break
600+
}
595601
}
596602
}
597603

0 commit comments

Comments
 (0)