summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2021-03-12 19:56:24 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2021-03-12 20:31:27 +0900
commit7310370a31fd7f4735caaebdc270578355119c3b (patch)
treed63b3ea82512a4c17a1725cc46e34033a2bea410
parent8ae94f0059d6201f3b05a4773b204eef01120625 (diff)
Fix truncation of colored line when --preview-window wrap is set
Fix #2346
-rw-r--r--src/terminal.go6
-rw-r--r--src/tui/light.go9
2 files changed, 7 insertions, 8 deletions
diff --git a/src/terminal.go b/src/terminal.go
index 98b9c354..3fab90fd 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -1320,8 +1320,9 @@ func (t *Terminal) renderPreviewText(unchanged bool) {
prefixWidth := 0
_, _, ansi = extractColor(line, ansi, func(str string, ansi *ansiState) bool {
trimmed := []rune(str)
+ trimmedLen := 0
if !t.previewOpts.wrap {
- trimmed, _ = t.trimRight(trimmed, maxWidth-t.pwindow.X())
+ trimmed, trimmedLen = t.trimRight(trimmed, maxWidth-t.pwindow.X())
}
str, width := t.processTabs(trimmed, prefixWidth)
prefixWidth += width
@@ -1331,7 +1332,8 @@ func (t *Terminal) renderPreviewText(unchanged bool) {
} else {
fillRet = t.pwindow.CFill(tui.ColPreview.Fg(), tui.ColPreview.Bg(), tui.AttrRegular, str)
}
- return fillRet == tui.FillContinue || t.previewOpts.wrap && fillRet == tui.FillNextLine
+ return trimmedLen == 0 &&
+ (fillRet == tui.FillContinue || t.previewOpts.wrap && fillRet == tui.FillNextLine)
})
t.previewer.scrollable = t.previewer.scrollable || t.pwindow.Y() == height-1 && t.pwindow.X() == t.pwindow.Width()
if fillRet == tui.FillNextLine {
diff --git a/src/tui/light.go b/src/tui/light.go
index 9c48b465..95e7bfd0 100644
--- a/src/tui/light.go
+++ b/src/tui/light.go
@@ -906,12 +906,6 @@ func (w *LightWindow) fill(str string, onMove func()) FillReturn {
for i, line := range allLines {
lines := wrapLine(line, w.posx, w.width, w.tabstop)
for j, wl := range lines {
- if w.posx >= w.Width()-1 && wl.displayWidth == 0 {
- if w.posy < w.height-1 {
- w.Move(w.posy+1, 0)
- }
- return FillNextLine
- }
w.stderrInternal(wl.text, false)
w.posx += wl.displayWidth
@@ -926,6 +920,9 @@ func (w *LightWindow) fill(str string, onMove func()) FillReturn {
}
}
}
+ if w.posx >= w.Width()-1 {
+ return FillNextLine
+ }
return FillContinue
}