1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-05-27 23:08:02 +02:00

Replaced regex with trim

This commit is contained in:
mjarkk 2018-11-10 08:14:35 +01:00
parent 17b4b4cb33
commit 1fd8cadd9e

View File

@ -6,7 +6,6 @@ import (
"bufio"
"os"
"os/exec"
"regexp"
"strings"
"sync"
"unicode/utf8"
@ -56,16 +55,12 @@ func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(s
}()
go func() {
// Regex to cleanup the command output
// sometimes the output words include unneeded spaces at eatch end of the string
re := regexp.MustCompile(`(^\s*)|(\s*$)`)
scanner := bufio.NewScanner(tty)
scanner.Split(scanWordsWithNewLines)
for scanner.Scan() {
// canAsk prefrents calls to output when the program is already closed
if canAsk() {
toOutput := re.ReplaceAllString(scanner.Text(), "")
toOutput := strings.Trim(scanner.Text(), " ")
cmdOutput = append(cmdOutput, toOutput)
toWrite := output(toOutput)
if len(toWrite) > 0 {