Fix info not updated after track-current is disabled due to race condition

This commit is contained in:
Junegunn Choi 2025-03-26 16:00:05 +09:00
parent 998c57442b
commit dac5b6fde1
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -4625,11 +4625,7 @@ func (t *Terminal) Loop() error {
// U t.uiMutex |
t.uiMutex.Lock()
t.mutex.Lock()
printInfo := util.RunOnce(func() {
if !t.resizeIfNeeded() {
t.printInfo()
}
})
info := false
for _, key := range keys {
req := util.EventType(key)
value := (*events)[req]
@ -4637,15 +4633,14 @@ func (t *Terminal) Loop() error {
case reqPrompt:
t.printPrompt()
if t.infoStyle == infoInline || t.infoStyle == infoInlineRight {
printInfo()
info = true
}
case reqInfo:
printInfo()
info = true
case reqList:
t.printList()
currentIndex := t.currentIndex()
focusChanged := focusedIndex != currentIndex
info := false
if focusChanged && focusedIndex >= 0 && t.track == trackCurrent {
t.track = trackDisabled
info = true
@ -4657,9 +4652,6 @@ func (t *Terminal) Loop() error {
info = true
}
}
if info {
printInfo()
}
if focusChanged || version != t.version {
version = t.version
focusedIndex = currentIndex
@ -4751,6 +4743,9 @@ func (t *Terminal) Loop() error {
return
}
}
if info && !t.resizeIfNeeded() {
t.printInfo()
}
t.flush()
t.mutex.Unlock()
t.uiMutex.Unlock()