Skip to content

Commit 375d765

Browse files
committed
Fix key filtering: add partial matching and restore value on escape
- Auto-wrap filter patterns with wildcards for partial matching (e.g., 'user' becomes '*user*') - Preserve explicit glob patterns when user includes *, ?, or [] characters - Restore previous pattern value when pressing escape to cancel
1 parent 205ec02 commit 375d765

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

internal/ui/update.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package ui
33
import (
44
"sort"
55
"strconv"
6+
"strings"
67
"time"
78

89
"redis/internal/cmd"
@@ -817,13 +818,19 @@ func (m Model) handleKeysScreen(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
817818
if m.PatternInput.Focused() {
818819
switch msg.String() {
819820
case "enter":
820-
m.KeyPattern = m.PatternInput.Value()
821+
pattern := m.PatternInput.Value()
822+
// Auto-wrap with wildcards if no glob characters present for partial matching
823+
if pattern != "" && !strings.ContainsAny(pattern, "*?[]") {
824+
pattern = "*" + pattern + "*"
825+
}
826+
m.KeyPattern = pattern
821827
m.PatternInput.Blur()
822828
m.KeyCursor = 0
823829
m.Loading = true
824830
return m, cmd.LoadKeysCmd(m.KeyPattern, 0, 100)
825831
case "esc":
826832
m.PatternInput.Blur()
833+
m.PatternInput.SetValue(m.KeyPattern) // Restore previous value on cancel
827834
default:
828835
var inputCmd tea.Cmd
829836
m.PatternInput, inputCmd = m.PatternInput.Update(msg)

0 commit comments

Comments
 (0)