mirror of
https://github.com/junegunn/fzf.git
synced 2026-05-25 17:58:50 +08:00
Defer list rendering until pending event actions are processed
This commit is contained in:
+11
-1
@@ -392,6 +392,7 @@ type Terminal struct {
|
|||||||
hasLoadActions bool
|
hasLoadActions bool
|
||||||
hasResizeActions bool
|
hasResizeActions bool
|
||||||
triggerLoad bool
|
triggerLoad bool
|
||||||
|
pendingReqList bool
|
||||||
filterSelection bool
|
filterSelection bool
|
||||||
reading bool
|
reading bool
|
||||||
running *util.AtomicBool
|
running *util.AtomicBool
|
||||||
@@ -1897,6 +1898,7 @@ func (t *Terminal) UpdateList(result MatchResult) {
|
|||||||
}
|
}
|
||||||
if t.triggerLoad {
|
if t.triggerLoad {
|
||||||
t.triggerLoad = false
|
t.triggerLoad = false
|
||||||
|
t.pendingReqList = true
|
||||||
t.eventChan <- tui.Load.AsEvent()
|
t.eventChan <- tui.Load.AsEvent()
|
||||||
}
|
}
|
||||||
// Search for the tracked item by nth key
|
// Search for the tracked item by nth key
|
||||||
@@ -1947,6 +1949,7 @@ func (t *Terminal) UpdateList(result MatchResult) {
|
|||||||
case 0:
|
case 0:
|
||||||
zero := tui.Zero.AsEvent()
|
zero := tui.Zero.AsEvent()
|
||||||
if _, prs := t.keymap[zero]; prs {
|
if _, prs := t.keymap[zero]; prs {
|
||||||
|
t.pendingReqList = true
|
||||||
t.eventChan <- zero
|
t.eventChan <- zero
|
||||||
}
|
}
|
||||||
// --sync, only 'focus' is bound, but no items to focus
|
// --sync, only 'focus' is bound, but no items to focus
|
||||||
@@ -1954,14 +1957,16 @@ func (t *Terminal) UpdateList(result MatchResult) {
|
|||||||
case 1:
|
case 1:
|
||||||
one := tui.One.AsEvent()
|
one := tui.One.AsEvent()
|
||||||
if _, prs := t.keymap[one]; prs {
|
if _, prs := t.keymap[one]; prs {
|
||||||
|
t.pendingReqList = true
|
||||||
t.eventChan <- one
|
t.eventChan <- one
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if t.hasResultActions {
|
if t.hasResultActions {
|
||||||
|
t.pendingReqList = true
|
||||||
t.eventChan <- tui.Result.AsEvent()
|
t.eventChan <- tui.Result.AsEvent()
|
||||||
}
|
}
|
||||||
updateList := !t.trackBlocked
|
updateList := !t.trackBlocked && !t.pendingReqList
|
||||||
updatePrompt := trackWasBlocked && !t.trackBlocked
|
updatePrompt := trackWasBlocked && !t.trackBlocked
|
||||||
t.mutex.Unlock()
|
t.mutex.Unlock()
|
||||||
|
|
||||||
@@ -7679,6 +7684,11 @@ func (t *Terminal) Loop() error {
|
|||||||
// Dispatch queued background requests
|
// Dispatch queued background requests
|
||||||
t.dispatchAsync()
|
t.dispatchAsync()
|
||||||
|
|
||||||
|
if t.pendingReqList {
|
||||||
|
t.pendingReqList = false
|
||||||
|
req(reqList)
|
||||||
|
}
|
||||||
|
|
||||||
t.mutex.Unlock() // Must be unlocked before touching reqBox
|
t.mutex.Unlock() // Must be unlocked before touching reqBox
|
||||||
|
|
||||||
if reload {
|
if reload {
|
||||||
|
|||||||
Reference in New Issue
Block a user