diff --git a/pkg/tasks/tasks.go b/pkg/tasks/tasks.go index 3768e0c19..0bc05f3d0 100644 --- a/pkg/tasks/tasks.go +++ b/pkg/tasks/tasks.go @@ -4,7 +4,9 @@ import ( "bufio" "fmt" "io" + "os" "os/exec" + "strconv" "sync" "sync/atomic" "time" @@ -313,6 +315,17 @@ func (self *ViewBufferManager) NewCmdTask(start func() (Cmd, io.Reader), prefix // this to work out how many more lines, if any, we still need to read. linesRead := 0 + // Set LAZYGIT_SLOW_RENDER= to sleep that long after each + // line is written to the view, stretching async loads out so the frames + // of a re-render become visible. Useful for debugging scroll/flicker + // behaviour; has no effect when the variable is unset. + var slowRenderPerLine time.Duration + if v := os.Getenv("LAZYGIT_SLOW_RENDER"); v != "" { + if ms, err := strconv.Atoi(v); err == nil { + slowRenderPerLine = time.Duration(ms) * time.Millisecond + } + } + outer: for { if stopped() { @@ -369,6 +382,10 @@ func (self *ViewBufferManager) NewCmdTask(start func() (Cmd, io.Reader), prefix lineWrittenChan <- struct{}{} linesRead++ + if slowRenderPerLine > 0 { + time.Sleep(slowRenderPerLine) + } + if linesRead == linesToRead.InitialRefreshAfter { // We have read enough lines to fill the view, so do a first refresh // here to show what we have. Continue reading and refresh again at