From 92e994ebf6c64575f7c20423179d431c1807601f Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Sat, 9 Feb 2019 00:48:23 +0300 Subject: [PATCH] Revert "only echo when the output pauses in shell-pipe" This reverts commit dd6a85f480e600df89e33291df502084ef27757b. --- app.go | 45 ++++++++++----------------------------------- client.go | 6 ++++++ 2 files changed, 16 insertions(+), 35 deletions(-) diff --git a/app.go b/app.go index 7e94a6a..257bdf4 100644 --- a/app.go +++ b/app.go @@ -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 } } diff --git a/client.go b/client.go index 0686b7d..28c9489 100644 --- a/client.go +++ b/client.go @@ -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) }