mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 15:46:26 -04:00
Fire queued ReadToEnd callbacks when the initial read reaches EOF
A task's read loop processes one LinesToRead request at a time. The initial request has a large line count and no Then callback; if the content is shorter than that, the loop hits EOF on the initial request and breaks out, abandoning any further requests still sitting in the readLines channel. So a ReadToEnd call that races a still-loading-but-shorter-than-its-initial-read view has its Then silently dropped: it isn't fired immediately (the channel was non-nil at call time) and it's never dequeued. On EOF, drain the queued requests and fire their Then callbacks before breaking out, since reaching EOF trivially satisfies any "read more" request. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0483b12864
commit
c8175c053f
|
|
@ -401,6 +401,21 @@ func (self *ViewBufferManager) NewCmdTask(start func() (Cmd, io.Reader), prefix
|
|||
// means a newer task is taking over and is still loading.
|
||||
self.loading.Store(false)
|
||||
callThen()
|
||||
// Any read requests that were queued while we were reading are
|
||||
// now trivially satisfied, since we've read everything. Fire
|
||||
// their callbacks instead of dropping them when we break out of
|
||||
// the loop below (and nil out readLines).
|
||||
drain:
|
||||
for {
|
||||
select {
|
||||
case queued := <-*self.readLines.Load():
|
||||
if queued.Then != nil {
|
||||
queued.Then()
|
||||
}
|
||||
default:
|
||||
break drain
|
||||
}
|
||||
}
|
||||
break outer
|
||||
}
|
||||
writeToView(append(line, '\n'))
|
||||
|
|
|
|||
Loading…
Reference in a new issue