mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-21 12:16:54 +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 := bufio.NewScanner(r)
|
||||||
scanner.Split(bufio.ScanLines)
|
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
|
loaded := false
|
||||||
|
|
||||||
go utils.Safe(func() {
|
go utils.Safe(func() {
|
||||||
@ -203,13 +217,15 @@ func (self *ViewBufferManager) NewCmdTask(start func() (*exec.Cmd, io.Reader), p
|
|||||||
break outer
|
break outer
|
||||||
case linesToRead := <-self.readLines:
|
case linesToRead := <-self.readLines:
|
||||||
for i := 0; i < linesToRead.Total; i++ {
|
for i := 0; i < linesToRead.Total; i++ {
|
||||||
|
var ok bool
|
||||||
|
var line []byte
|
||||||
select {
|
select {
|
||||||
case <-opts.Stop:
|
case <-opts.Stop:
|
||||||
break outer
|
break outer
|
||||||
default:
|
case line, ok = <-data:
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
ok := scanner.Scan()
|
|
||||||
loadingMutex.Lock()
|
loadingMutex.Lock()
|
||||||
if !loaded {
|
if !loaded {
|
||||||
self.beforeStart()
|
self.beforeStart()
|
||||||
@ -226,7 +242,7 @@ func (self *ViewBufferManager) NewCmdTask(start func() (*exec.Cmd, io.Reader), p
|
|||||||
self.onEndOfInput()
|
self.onEndOfInput()
|
||||||
break outer
|
break outer
|
||||||
}
|
}
|
||||||
writeToView(append(scanner.Bytes(), '\n'))
|
writeToView(append(line, '\n'))
|
||||||
|
|
||||||
if i+1 == linesToRead.InitialRefreshAfter {
|
if i+1 == linesToRead.InitialRefreshAfter {
|
||||||
// We have read enough lines to fill the view, so do a first refresh
|
// We have read enough lines to fill the view, so do a first refresh
|
||||||
|
Loading…
x
Reference in New Issue
Block a user