@@ -15,6 +15,13 @@ import (
15 "github.com/sahilm/fuzzy"
15 "github.com/sahilm/fuzzy"
19+ // Pre-compiled regex for checking if a string contains alphabetic characters.
20+ alphaRegex = regexp.MustCompile(`[a-zA-Z]`)
21+ // Pre-compiled regex for checking if a string is alphanumeric.
22+ alphanumericRegex = regexp.MustCompile(`^[a-zA-Z0-9]*$`)
18type FilterableItem interface {
25type FilterableItem interface {
20 FilterValue() string
27 FilterValue() string
@@ -165,8 +172,6 @@ func (f *filterableList[T]) View() string {
166// removes bindings that are used for search
173// removes bindings that are used for search
167func (f *filterableList[T]) updateKeyMaps() {
174func (f *filterableList[T]) updateKeyMaps() {
168− alphanumeric := regexp.MustCompile("^[a-zA-Z0-9]*$")
170 removeLettersAndNumbers := func(bindings []string) []string {
175 removeLettersAndNumbers := func(bindings []string) []string {
171 var keep []string
176 var keep []string
172 for _, b := range bindings {
177 for _, b := range bindings {
@@ -177,7 +182,7 @@ func (f *filterableList[T]) updateKeyMaps() {
177 if b == " " {
182 if b == " " {
180− m := alphanumeric.MatchString(b)
185+ m := alphanumericRegex.MatchString(b)
182 keep = append(keep, b)
187 keep = append(keep, b)