diff options
Diffstat (limited to 'pkg/tasks/tasks.go')
-rw-r--r-- | pkg/tasks/tasks.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/pkg/tasks/tasks.go b/pkg/tasks/tasks.go index 5854b4f46..8287b3927 100644 --- a/pkg/tasks/tasks.go +++ b/pkg/tasks/tasks.go @@ -33,12 +33,13 @@ type ViewBufferManager struct { readLines chan int // beforeStart is the function that is called before starting a new task - beforeStart func() - refreshView func() + beforeStart func() + refreshView func() + flushStaleCells func() } -func NewViewBufferManager(log *logrus.Entry, writer io.Writer, beforeStart func(), refreshView func()) *ViewBufferManager { - return &ViewBufferManager{Log: log, writer: writer, beforeStart: beforeStart, refreshView: refreshView, readLines: make(chan int, 1024)} +func NewViewBufferManager(log *logrus.Entry, writer io.Writer, beforeStart func(), refreshView func(), flushStaleCells func()) *ViewBufferManager { + return &ViewBufferManager{Log: log, writer: writer, beforeStart: beforeStart, refreshView: refreshView, flushStaleCells: flushStaleCells, readLines: make(chan int, 1024)} } func (m *ViewBufferManager) ReadLines(n int) { @@ -75,7 +76,7 @@ func (m *ViewBufferManager) NewCmdTask(r io.Reader, cmd *exec.Cmd, prefix string loaded := false go utils.Safe(func() { - ticker := time.NewTicker(time.Millisecond * 100) + ticker := time.NewTicker(time.Millisecond * 200) defer ticker.Stop() select { case <-ticker.C: @@ -114,6 +115,9 @@ func (m *ViewBufferManager) NewCmdTask(r io.Reader, cmd *exec.Cmd, prefix string default: } if !ok { + // if we're here then there's nothing left to scan from the source + // so we're at the EOF and can flush the stale content + m.flushStaleCells() m.refreshView() break outer } |