Fix filterSelection timing: only consume flag on new search results

Move the filterSelection check inside the revision-change guard so a
stale EvtSearchFin from a previous search cannot consume the flag
before the retransformed search results arrive.
This commit is contained in:
Junegunn Choi
2026-02-24 21:42:26 +09:00
parent e7d591af7e
commit e4ebf18508

View File

@@ -1860,19 +1860,22 @@ func (t *Terminal) UpdateList(result MatchResult) {
} }
t.revision = newRevision t.revision = newRevision
t.version++ t.version++
}
if t.filterSelection && t.multi > 0 && len(t.selected) > 0 { // Filter out selections that no longer match after with-nth change.
t.filterSelection = false // Must be inside the revision check so we don't consume the flag
matchMap := t.resultMerger.ToMap() // on a stale EvtSearchFin from a previous search.
filtered := make(map[int32]selectedItem) if t.filterSelection && t.multi > 0 && len(t.selected) > 0 {
for k, v := range t.selected { matchMap := t.resultMerger.ToMap()
if _, matched := matchMap[k]; matched { filtered := make(map[int32]selectedItem)
filtered[k] = v for k, v := range t.selected {
if _, matched := matchMap[k]; matched {
filtered[k] = v
}
} }
t.selected = filtered
} }
t.selected = filtered t.filterSelection = false
} }
t.filterSelection = false
if t.triggerLoad { if t.triggerLoad {
t.triggerLoad = false t.triggerLoad = false
t.eventChan <- tui.Load.AsEvent() t.eventChan <- tui.Load.AsEvent()