Skip to content
Myr

Fix truncation of colored line when --preview-window wrap is set

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fix #2346

authored by Junegunn Choi · committed by Junegunn Choi · parent 8ae94f0 · Browse files · 2 files+7 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+7 added−8 removed

  • other:+7 added−8 removed

2 files+7 added−8 removed

modified:src/tui/light.go+3 added-6 removed
904 unmodified lines
905 allLines := strings.Split(str, "\n")906 for i, line := range allLines {907 lines := wrapLine(line, w.posx, w.width, w.tabstop)908 for j, wl := range lines {909 if w.posx >= w.Width()-1 && wl.displayWidth == 0 {910 if w.posy < w.height-1 {911 w.Move(w.posy+1, 0)912 }913 return FillNextLine914 }909 w.stderrInternal(wl.text, false)910 w.posx += wl.displayWidth911912 // Wrap line
6 unmodified lines
919 onMove()920 }921 }922 }923 if w.posx >= w.Width()-1 {924 return FillNextLine925 }926 return FillContinue927}928929func (w *LightWindow) setBg() {
38 unmodified lines
modified:src/terminal.go+4 added-2 removed
1318 unmodified lines
1319 var fillRet tui.FillReturn1320 prefixWidth := 01321 _, _, ansi = extractColor(line, ansi, func(str string, ansi *ansiState) bool {1322 trimmed := []rune(str)1323 trimmedLen := 01324 if !t.previewOpts.wrap {1324 trimmed, _ = t.trimRight(trimmed, maxWidth-t.pwindow.X())1325 trimmed, trimmedLen = t.trimRight(trimmed, maxWidth-t.pwindow.X())1326 }1327 str, width := t.processTabs(trimmed, prefixWidth)1328 prefixWidth += width1329 if t.theme.Colored && ansi != nil && ansi.colored() {
1 unmodified line
1331 fillRet = t.pwindow.CFill(ansi.fg, ansi.bg, ansi.attr, str)1332 } else {1333 fillRet = t.pwindow.CFill(tui.ColPreview.Fg(), tui.ColPreview.Bg(), tui.AttrRegular, str)1334 }1334 return fillRet == tui.FillContinue || t.previewOpts.wrap && fillRet == tui.FillNextLine1335 return trimmedLen == 0 &&1336 (fillRet == tui.FillContinue || t.previewOpts.wrap && fillRet == tui.FillNextLine)1337 })1338 t.previewer.scrollable = t.previewer.scrollable || t.pwindow.Y() == height-1 && t.pwindow.X() == t.pwindow.Width()1339 if fillRet == tui.FillNextLine {1340 continue
1395 unmodified lines