diff options
author | Andrew Savinykh <658865+AndrewSav@users.noreply.github.com> | 2023-07-22 09:13:54 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-07-22 09:14:05 +1000 |
commit | a7969aef2c0d597ca97f060836233f21b2b68bc6 (patch) | |
tree | 513b5748dfdfe033bebc674ec065b17f075c3dca | |
parent | 39c900c7e709c9f18a84d6aa8f3f78f371af5136 (diff) |
Fix rendering to main view on windowsv0.39.2
-rw-r--r-- | pkg/tasks/tasks.go | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/pkg/tasks/tasks.go b/pkg/tasks/tasks.go index 33c46380f..8fcebf4b4 100644 --- a/pkg/tasks/tasks.go +++ b/pkg/tasks/tasks.go @@ -164,6 +164,20 @@ func (self *ViewBufferManager) NewCmdTask(start func() (*exec.Cmd, io.Reader), p scanner := bufio.NewScanner(r) scanner.Split(bufio.ScanLines) + data := make(chan []byte) + + // We're reading from the scanner in a separate goroutine because on windows + // if running git through a shim, we sometimes kill the parent process without + // killing its children, meaning the scanner blocks forever. This solution + // leaves us with a dead goroutine, but it's better than blocking all + // rendering to main views. + go utils.Safe(func() { + for scanner.Scan() { + data <- scanner.Bytes() + } + close(data) + }) + loaded := false go utils.Safe(func() { @@ -203,13 +217,15 @@ func (self *ViewBufferManager) NewCmdTask(start func() (*exec.Cmd, io.Reader), p break outer case linesToRead := <-self.readLines: for i := 0; i < linesToRead.Total; i++ { + var ok bool + var line []byte select { case <-opts.Stop: break outer - default: + case line, ok = <-data: + break } - ok := scanner.Scan() loadingMutex.Lock() if !loaded { self.beforeStart() @@ -226,7 +242,7 @@ func (self *ViewBufferManager) NewCmdTask(start func() (*exec.Cmd, io.Reader), p self.onEndOfInput() break outer } - writeToView(append(scanner.Bytes(), '\n')) + writeToView(append(line, '\n')) if i+1 == linesToRead.InitialRefreshAfter { // We have read enough lines to fill the view, so do a first refresh |