From 5d6eb5bfd64c6d5d773c71159d819b651dd5f7f1 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 28 May 2017 02:26:42 +0900 Subject: [PATCH] Respect ANSI color state from the previous line in preview output --- src/terminal.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/terminal.go b/src/terminal.go index 4e7da73..fdd3caa 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -954,6 +954,7 @@ func (t *Terminal) printPreview() { } reader := bufio.NewReader(strings.NewReader(t.previewer.text)) lineNo := -t.previewer.offset + var ansi *ansiState for { line, err := reader.ReadString('\n') eof := err == io.EOF @@ -965,7 +966,7 @@ func (t *Terminal) printPreview() { break } else if lineNo > 0 { var fillRet tui.FillReturn - extractColor(line, nil, func(str string, ansi *ansiState) bool { + _, _, ansi = extractColor(line, ansi, func(str string, ansi *ansiState) bool { trimmed := []rune(str) if !t.preview.wrap { trimmed, _ = t.trimRight(trimmed, maxWidth-t.pwindow.X())