Skip to content
Myr

Fix tab width after ANSI reset code in preview window

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

Close #1423

authored by Junegunn Choi · committed by Junegunn Choi · parent 5624a89 · Browse files · 2 files+9 added−1 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+9 added−1 removed

  • tests:+6 added−0 removed
  • other:+3 added−1 removed

2 files+9 added−1 removed

modified:src/terminal.go+3 added-1 removed
1034 unmodified lines
1035 t.pwindow.Y() == height-1 && t.pwindow.X() > 0 {1036 break1037 } else if lineNo > 0 {1038 var fillRet tui.FillReturn1039 prefixWidth := 01040 _, _, ansi = extractColor(line, ansi, func(str string, ansi *ansiState) bool {1041 trimmed := []rune(str)1042 if !t.preview.wrap {1043 trimmed, _ = t.trimRight(trimmed, maxWidth-t.pwindow.X())1044 }1044 str, _ = t.processTabs(trimmed, 0)1045 str, width := t.processTabs(trimmed, prefixWidth)1046 prefixWidth += width1047 if t.theme != nil && ansi != nil && ansi.colored() {1048 fillRet = t.pwindow.CFill(ansi.fg, ansi.bg, ansi.attr, str)1049 } else {1050 fillRet = t.pwindow.CFill(tui.ColNormal.Fg(), tui.ColNormal.Bg(), tui.AttrRegular, str)
992 unmodified lines
modified:test/test_go.rb+6 added
1530 unmodified lines
1531 tmux.until { |lines| lines[-3] == '> aaaaa' }1532 tmux.until { |lines| lines[-4] == ' b' }1533 tmux.until { |lines| lines[-5] == ' ccc' }1534 end15351536 def test_preview_correct_tab_width_after_ansi_reset_code1537 writelines tempname, ["\x1b[31m+\x1b[m\t\x1b[32mgreen"]1538 tmux.send_keys "#{FZF} --preview 'cat #{tempname}'", :Enter1539 tmux.until { |lines| lines[1].include?('+ green') }1540 end1541end15421543module TestShell1544 def setup
370 unmodified lines