Revert "only echo when the output pauses in shell-pipe"

This reverts commit dd6a85f480.
This commit is contained in:
Gokcehan 2019-02-09 00:48:23 +03:00
parent 245db502cc
commit 92e994ebf6
2 changed files with 16 additions and 35 deletions

45
app.go
View File

@ -136,12 +136,6 @@ func (app *app) loop() {
clientChan := app.ui.readExpr()
serverChan := readExpr()
for _, path := range gConfigPaths {
if _, err := os.Stat(path); !os.IsNotExist(err) {
app.readFile(path)
}
}
if gCommand != "" {
p := newParser(strings.NewReader(gCommand))
@ -346,41 +340,22 @@ func (app *app) runShell(s string, args []string, prefix string) {
switch prefix {
case "%":
app.cmd = cmd
app.cmdOutBuf = nil
app.ui.msg = ""
app.ui.cmdPrefix = ">"
reader := bufio.NewReader(out)
bytes := make(chan byte, 1000)
go func() {
app.cmd = cmd
app.cmdOutBuf = nil
app.ui.msg = ""
app.ui.cmdPrefix = ">"
reader := bufio.NewReader(out)
for {
b, err := reader.ReadByte()
if err == io.EOF {
break
}
bytes <- b
}
close(bytes)
}()
go func() {
loop:
for {
select {
case b, ok := <-bytes:
switch {
case !ok:
break loop
case b == '\n' || b == '\r':
app.ui.exprChan <- &callExpr{"echo", []string{string(app.cmdOutBuf)}, 1}
app.cmdOutBuf = nil
default:
app.cmdOutBuf = append(app.cmdOutBuf, b)
}
default:
app.ui.exprChan <- &callExpr{"echo", []string{string(app.cmdOutBuf)}, 1}
app.cmdOutBuf = append(app.cmdOutBuf, b)
app.ui.exprChan <- &callExpr{"echo", []string{string(app.cmdOutBuf)}, 1}
if b == '\n' || b == '\r' {
app.cmdOutBuf = nil
}
}

View File

@ -33,6 +33,12 @@ func run() {
app := newApp()
for _, path := range gConfigPaths {
if _, err := os.Stat(path); !os.IsNotExist(err) {
app.readFile(path)
}
}
if err := app.nav.readMarks(); err != nil {
app.ui.printf("reading marks file: %s", err)
}