mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-12-23 11:29:01 +00:00
'reload' action should reset --header-lines
This commit is contained in:
parent
deccf20a35
commit
7e1c0f39e7
13
src/core.go
13
src/core.go
@ -225,6 +225,12 @@ func Run(opts *Options, revision string) {
|
|||||||
reading := true
|
reading := true
|
||||||
ticks := 0
|
ticks := 0
|
||||||
var nextCommand *string
|
var nextCommand *string
|
||||||
|
restart := func(command string) {
|
||||||
|
reading = true
|
||||||
|
chunkList.Clear()
|
||||||
|
header = make([]string, 0, opts.HeaderLines)
|
||||||
|
go reader.restart(command)
|
||||||
|
}
|
||||||
eventBox.Watch(EvtReadNew)
|
eventBox.Watch(EvtReadNew)
|
||||||
for {
|
for {
|
||||||
delay := true
|
delay := true
|
||||||
@ -245,9 +251,8 @@ func Run(opts *Options, revision string) {
|
|||||||
case EvtReadNew, EvtReadFin:
|
case EvtReadNew, EvtReadFin:
|
||||||
clearCache := false
|
clearCache := false
|
||||||
if evt == EvtReadFin && nextCommand != nil {
|
if evt == EvtReadFin && nextCommand != nil {
|
||||||
chunkList.Clear()
|
|
||||||
clearCache = true
|
clearCache = true
|
||||||
go reader.restart(*nextCommand)
|
restart(*nextCommand)
|
||||||
nextCommand = nil
|
nextCommand = nil
|
||||||
} else {
|
} else {
|
||||||
reading = reading && evt == EvtReadNew
|
reading = reading && evt == EvtReadNew
|
||||||
@ -271,9 +276,7 @@ func Run(opts *Options, revision string) {
|
|||||||
reader.terminate()
|
reader.terminate()
|
||||||
nextCommand = command
|
nextCommand = command
|
||||||
} else {
|
} else {
|
||||||
reading = true
|
restart(*command)
|
||||||
chunkList.Clear()
|
|
||||||
go reader.restart(*command)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
snapshot, _ := chunkList.Snapshot()
|
snapshot, _ := chunkList.Snapshot()
|
||||||
|
@ -1623,14 +1623,14 @@ class TestGoFZF < TestBase
|
|||||||
end
|
end
|
||||||
|
|
||||||
def test_reload
|
def test_reload
|
||||||
tmux.send_keys %(seq 1000 | #{FZF} --bind 'change:reload(seq {q}),a:reload(seq 100),b:reload:seq 200'), :Enter
|
tmux.send_keys %(seq 1000 | #{FZF} --bind 'change:reload(seq {q}),a:reload(seq 100),b:reload:seq 200' --header-lines 2), :Enter
|
||||||
tmux.until { |lines| lines.match_count == 1000 }
|
tmux.until { |lines| lines.match_count == 998 }
|
||||||
tmux.send_keys 'a'
|
tmux.send_keys 'a'
|
||||||
tmux.until { |lines| lines.item_count == 100 && lines.match_count == 100 }
|
tmux.until { |lines| lines.item_count == 98 && lines.match_count == 98 }
|
||||||
tmux.send_keys 'b'
|
tmux.send_keys 'b'
|
||||||
tmux.until { |lines| lines.item_count == 200 && lines.match_count == 200 }
|
tmux.until { |lines| lines.item_count == 198 && lines.match_count == 198 }
|
||||||
tmux.send_keys '555'
|
tmux.send_keys '555'
|
||||||
tmux.until { |lines| lines.item_count == 555 && lines.match_count == 1 }
|
tmux.until { |lines| lines.item_count == 553 && lines.match_count == 1 }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user