mirror of
https://github.com/zoriya/bubbles.git
synced 2026-08-05 04:36:07 +00:00
fix(key): make matches accept any stringer
This commit is contained in:
+2
-4
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user