1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-15 00:15:32 +02:00

add some safe goroutines

WIP
This commit is contained in:
Jesse Duffield
2020-10-07 21:19:38 +11:00
parent ba4c3e5bc4
commit 79e59d5460
15 changed files with 84 additions and 64 deletions

View File

@ -9,6 +9,7 @@ import (
"unicode/utf8"
"github.com/go-errors/errors"
"github.com/jesseduffield/lazygit/pkg/utils"
"github.com/creack/pty"
)
@ -31,14 +32,14 @@ func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(s
return err
}
go func() {
go utils.Safe(func() {
scanner := bufio.NewScanner(ptmx)
scanner.Split(scanWordsWithNewLines)
for scanner.Scan() {
toOutput := strings.Trim(scanner.Text(), " ")
_, _ = ptmx.WriteString(output(toOutput))
}
}()
})
err = cmd.Wait()
ptmx.Close()