mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-11 11:42:12 +02:00
Fix rendering to main view on windows
This commit is contained in:
parent
39c900c7e7
commit
a7969aef2c
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user