From 26895da96918f9b1956a04981c8af5f3e42fcbd8 Mon Sep 17 00:00:00 2001 From: Michael Kelley Date: Sun, 23 Oct 2016 20:45:45 -0700 Subject: Implement tcell-based renderer --- src/reader.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/reader.go') diff --git a/src/reader.go b/src/reader.go index 05426660..15a0f44e 100644 --- a/src/reader.go +++ b/src/reader.go @@ -4,6 +4,7 @@ import ( "bufio" "io" "os" + "runtime" "github.com/junegunn/fzf/src/util" ) @@ -39,9 +40,15 @@ func (r *Reader) feed(src io.Reader) { // ReadBytes returns err != nil if and only if the returned data does not // end in delim. bytea, err := reader.ReadBytes(delim) + byteaLen := len(bytea) if len(bytea) > 0 { if err == nil { - bytea = bytea[:len(bytea)-1] + // get rid of carriage return if under Windows: + if runtime.GOOS == "windows" && byteaLen >= 2 && bytea[byteaLen-2] == byte('\r') { + bytea = bytea[:byteaLen-2] + } else { + bytea = bytea[:byteaLen-1] + } } if r.pusher(bytea) { r.eventBox.Set(EvtReadNew, nil) -- cgit v1.2.3