mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-29 23:17:32 +02:00
Replaced regex with trim
This commit is contained in:
parent
17b4b4cb33
commit
1fd8cadd9e
@ -6,7 +6,6 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"regexp"
|
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
@ -56,16 +55,12 @@ func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(s
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
go func() {
|
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 := bufio.NewScanner(tty)
|
||||||
scanner.Split(scanWordsWithNewLines)
|
scanner.Split(scanWordsWithNewLines)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
// canAsk prefrents calls to output when the program is already closed
|
// canAsk prefrents calls to output when the program is already closed
|
||||||
if canAsk() {
|
if canAsk() {
|
||||||
toOutput := re.ReplaceAllString(scanner.Text(), "")
|
toOutput := strings.Trim(scanner.Text(), " ")
|
||||||
cmdOutput = append(cmdOutput, toOutput)
|
cmdOutput = append(cmdOutput, toOutput)
|
||||||
toWrite := output(toOutput)
|
toWrite := output(toOutput)
|
||||||
if len(toWrite) > 0 {
|
if len(toWrite) > 0 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user