Skip to content

Commit

Permalink
feat: "cancel" search and don't allow multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
cfoust committed Nov 15, 2023
1 parent 90688bc commit 67d322d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/mux/screen/replay/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ func (r *Replay) waitProgress() tea.Cmd {
}

func (r *Replay) handleSearchResult(msg SearchResultEvent) (taro.Model, tea.Cmd) {
if r.isWaiting != true {
return r, nil
}

r.isWaiting = false

// TODO(cfoust): 10/13/23 handle error
Expand Down
10 changes: 10 additions & 0 deletions pkg/mux/screen/replay/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ func (r *Replay) Update(msg tea.Msg) (taro.Model, tea.Cmd) {
r.isPlaying = false
switch msg.Type {
case ActionQuit:
// Ignore an in-progress search
if r.isWaiting {
r.isWaiting = false
return r, nil
}

if r.isCopyMode() {
if r.isSelecting {
r.isSelecting = false
Expand Down Expand Up @@ -130,6 +136,10 @@ func (r *Replay) Update(msg tea.Msg) (taro.Model, tea.Cmd) {
case ActionSearchAgain, ActionSearchReverse:
r.searchAgain(msg.Type != ActionSearchReverse)
case ActionSearchForward, ActionSearchBackward:
if r.isWaiting {
return r, nil
}

r.mode = ModeInput
r.isForward = msg.Type == ActionSearchForward
r.searchInput.Reset()
Expand Down

0 comments on commit 67d322d

Please sign in to comment.