From 10d51937f24fc69673cfe2339803f2e2b328b34d Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Mon, 22 Jul 2024 15:37:01 -0400 Subject: [PATCH] fix(key): make matches accept any stringer --- key/debug.txt | 0 key/key.go | 6 ++---- 2 files changed, 2 insertions(+), 4 deletions(-) create mode 100644 key/debug.txt diff --git a/key/debug.txt b/key/debug.txt new file mode 100644 index 0000000..e69de29 diff --git a/key/key.go b/key/key.go index b6f486d..462d5e2 100644 --- a/key/key.go +++ b/key/key.go @@ -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 {