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