From 501d15e410fb3fca619d6c0bfa026b57a9ffd4e2 Mon Sep 17 00:00:00 2001 From: Hayden Hargreaves Date: Thu, 9 Apr 2026 15:17:07 -0700 Subject: [PATCH] WIP: working on search execution --- internal/action/search.go | 32 ++++++++++++++++++++++++++++++++ internal/input/keymap.go | 4 ++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/internal/action/search.go b/internal/action/search.go index f491aa5..35e82b1 100644 --- a/internal/action/search.go +++ b/internal/action/search.go @@ -15,6 +15,9 @@ func (a EnterSearchMode) Execute(m Model) tea.Cmd { search := m.SearchState() search.Forword = a.Forward + // BUG: Not sure if this is safe? + m.SetCommandOutput(nil) + m.SetSearchState(search) m.SetMode(core.SearchMode) return nil @@ -144,3 +147,32 @@ func (a SearchDeletePreviousWord) Execute(m Model) tea.Cmd { return nil } + +type SearchExecute struct{} + +func (a SearchExecute) Execute(m Model) tea.Cmd { + search := m.SearchState() + + // Exit normally + defer func() { + act := ExitSearchMode{} + act.Execute(m) + }() + + if !search.Forword { + m.SetCommandOutput(&core.CommandOutput{ + Lines: []string{"reverse search not implemented yet."}, + Inline: true, + IsError: true, + }) + return nil + } + + // Do the search + win := m.ActiveWindow() + buf := m.ActiveBuffer() + + x, y := win.Cursor.Col, win.Cursor.Line + + return nil +} diff --git a/internal/input/keymap.go b/internal/input/keymap.go index f6ac66b..bcee96e 100644 --- a/internal/input/keymap.go +++ b/internal/input/keymap.go @@ -272,8 +272,8 @@ func NewSearchKeymap() *Keymap { }, operators: map[string]action.Operator{}, // this will likely be empty actions: map[string]action.Action{ - "esc": action.ExitSearchMode{}, - // "enter": action.CommandExecute{Registry: command.DefaultRegistry}, + "esc": action.ExitSearchMode{}, + "enter": action.SearchExecute{}, "backspace": action.SearchBackspace{}, "delete": action.SearchDelete{}, "ctrl+w": action.SearchDeletePreviousWord{},