Skip to content
Myr

Fix stale progress in --listen status payload (#4907)

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

- progress was set to 100 by every UpdateList, partial results included, and never reset when a search started - So a GET could report a new query, the previous result set, and progress 100, and a client had no way to tell it was stale - Now cleared where the search is requested and set to 100 only on the final result. Query and the reset happen in the same locked section that dumpStatus locks, so query == X with progress 100 means the matches belong to X Fix #4903

authored by Junegunn Choi · committed by GitHub · parent 1372d04 · Browse files · 3 files+29 added−1 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+29 added−1 removed

  • tests:+23 added−0 removed
  • other:+6 added−1 removed

3 files+29 added−1 removed

modified:src/terminal.go+4 added-1 removed
2057 unmodified lines
2058 if t.targetIndex != minItem.Index() {2059 prevIndex = t.targetIndex2060 t.targetIndex = minItem.Index()2061 }2062 if result.final() {2062 t.progress = 1002063 t.progress = 1002064 }2065 t.merger = merger2066 t.resultMerger = merger2067 t.passMerger = result.passMerger2068 if t.raw {
6529 unmodified lines
85988599 reload := changed || newCommand != nil8600 if reload {8601 t.wait.searching = true8602 t.progress = 08603 }8604 var reloadRequest *searchRequest8605 if reload {8606 reloadRequest = &searchRequest{sort: t.sort, sync: reloadSync, nth: newNth, withNth: newWithNth, headerLines: newHeaderLines, command: newCommand, environ: t.environ(), changed: changed, denylist: denylist, revision: t.resultMerger.Revision()}
244 unmodified lines
modified:test/test_server.rb+23 added
53 unmodified lines
54 setup55 end56 end5758 def test_listen_progress59 tmux.send_keys "seq 10 | #{FZF} --listen 6266", :Enter60 tmux.until { |lines| assert_equal 10, lines.match_count }61 uri = URI('http://localhost:6266')62 state = -> { JSON.parse(Net::HTTP.get(uri), symbolize_names: true) }6364 # Idle: the last search is complete65 assert_equal 100, state.call[:progress]6667 # While a search is running, progress is not left at 100 from the68 # previous one, so it can tell a settled snapshot from a stale one69 Net::HTTP.post(uri, 'reload(sleep 1; seq 100)')70 tmux.until { assert_equal 0, state.call[:progress] }7172 # Settled: matches belong to the snapshot that reports 10073 tmux.until { |lines| assert_equal 100, lines.match_count }74 tmux.until do75 st = state.call76 assert_equal 100, st[:progress]77 assert_equal 100, st[:matchCount]78 end79 end8081 def test_listen_with_api_key82 uri = URI('http://localhost:6266')83 tmux.send_keys 'seq 10 | FZF_API_KEY=123abc fzf --listen 6266', :Enter84 tmux.until { |lines| assert_equal 10, lines.match_count }
26 unmodified lines
modified:CHANGELOG.md+2 added
4 unmodified lines
5------6- Fixed an escape sequence split across reads being parsed as a fragment, which leaked the rest into the query (#4899)7 - e.g. A terminal answering the startup `DECRQM` query late left `?2004;2$y`, CTRL-UP left `5A`, and SGR mouse input left `0;1;1M`8- Fixed `--tiebreak=pathname` not detecting the last path separator when the line contains a non-ASCII character before it (#4902)9- Fixed `progress` in the `--listen` status payload staying at 100 while a new search was running, which made a snapshot with a new query and the previous result set look complete (#4903)10 - It is now reset when a search starts and reaches 100 on the final result, so `progress` of 100 means the matches belong to the query reported next to them11- Fixed adaptive height not reserving a line for the divider of an inline header or footer border, so the list came up one line short for each of them (#4904)12 - e.g. `seq 10 | fzf --height=~100% --list-border --header-lines=1 --header-lines-border=inline`13- Vim plugin14 - fzf no longer blocks the editor, so live previews keep working while fzf is open
3434 unmodified lines