diff --git a/pkg/tasks/tasks.go b/pkg/tasks/tasks.go index c9b5aaa5a..dec232189 100644 --- a/pkg/tasks/tasks.go +++ b/pkg/tasks/tasks.go @@ -380,6 +380,21 @@ func (self *ViewBufferManager) NewCmdTask(start func() (Cmd, io.Reader), prefix // are UI-thread-only, so run it there. _ = self.onUIThread(self.onEndOfInput) 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 := <-readLines: + if queued.Then != nil { + queued.Then() + } + default: + break drain + } + } break outer } writeToView(append(line, '\n')) diff --git a/pkg/tasks/tasks_test.go b/pkg/tasks/tasks_test.go index 4211dcb08..d9ec7e4d4 100644 --- a/pkg/tasks/tasks_test.go +++ b/pkg/tasks/tasks_test.go @@ -248,10 +248,7 @@ func TestNewCmdTaskQueuedReadAtEndOfInput(t *testing.T) { wg.Wait() - /* EXPECTED: assert.True(t, thenCalled) - ACTUAL: */ - assert.False(t, thenCalled) } func TestNewCmdTaskRefresh(t *testing.T) {