fix(key): make matches accept any stringer

This commit is contained in:
Ayman Bagabas
2024-07-22 15:37:01 -04:00
parent f677949ded
commit 10d51937f2
2 changed files with 2 additions and 4 deletions
View File
+2 -4
View File
@@ -36,9 +36,7 @@
// to render help text for keystrokes in your views.
package key
import (
tea "github.com/charmbracelet/bubbletea"
)
import "fmt"
// Binding describes a set of keybindings and, optionally, their associated
// help text.
@@ -129,7 +127,7 @@ type Help struct {
}
// Matches checks if the given KeyMsg matches the given bindings.
func Matches(k tea.KeyPressMsg, b ...Binding) bool {
func Matches[T fmt.Stringer](k T, b ...Binding) bool {
keys := k.String()
for _, binding := range b {
for _, v := range binding.keys {