Skip to content
Myr

Fix search not triggered when query change and reload happen at the same time

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fix #3268

authored by Junegunn Choi · committed by Junegunn Choi · parent 5c2f85c · Browse files · 3 files+17 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+17 added−2 removed

  • tests:+5 added−0 removed
  • other:+12 added−2 removed

3 files+17 added−2 removed

modified:src/core.go+10 added-1 removed
297 unmodified lines
298 matcher.Reset(snapshot, input(reset), false, !reading, sort, reset)299300 case EvtSearchNew:301 var command *string302 var changed bool303 switch val := value.(type) {304 case searchRequest:305 sort = val.sort306 command = val.command307 changed = val.changed308 if command != nil {309 useSnapshot = val.sync310 }311 }
3 unmodified lines
315 nextCommand = command316 } else {317 restart(*command)318 }319 }320 if !changed {321 break322 }323 if !useSnapshot {320 snapshot, _ = chunkList.Snapshot()324 newSnapshot, _ := chunkList.Snapshot()325 // We want to avoid showing empty list when reload is triggered326 // and the query string is changed at the same time i.e. command != nil && changed327 if command == nil || len(newSnapshot) > 0 {328 snapshot = newSnapshot329 }330 }331 reset := !useSnapshot && clearCache()332 matcher.Reset(snapshot, input(reset), true, !reading, sort, reset)333 delay = false
52 unmodified lines
modified:src/terminal.go+2 added-1 removed
406 unmodified lines
407type searchRequest struct {408 sort bool409 sync bool410 command *string411 changed bool412}413414type previewRequest struct {415 template string
3206 unmodified lines
36223623 t.mutex.Unlock() // Must be unlocked before touching reqBox36243625 if changed || newCommand != nil {3625 t.eventBox.Set(EvtSearchNew, searchRequest{sort: t.sort, sync: reloadSync, command: newCommand})3626 t.eventBox.Set(EvtSearchNew, searchRequest{sort: t.sort, sync: reloadSync, command: newCommand, changed: changed})3627 }3628 for _, event := range events {3629 t.reqBox.Set(event, nil)3630 }
65 unmodified lines
modified:test/test_go.rb+5 added
2859 unmodified lines
2860 tmux.until { |lines| assert_equal 10, lines.item_count }2861 tmux.send_keys :c2862 tmux.until { |lines| assert_equal 0, lines.match_count }2863 end28642865 def test_reload_and_change2866 tmux.send_keys "(echo foo; echo bar) | #{FZF} --bind 'load:reload-sync(sleep 60)+change-query(bar)'", :Enter2867 tmux.until { |lines| assert_equal 1, lines.match_count }2868 end2869end28702871module TestShell2872 def setup
481 unmodified lines