Skip to content
Myr

Fix missing wrap sign at ANSI color boundary

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

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

  • tests:+27 added−0 removed
  • other:+11 added−1 removed

2 files+38 added−1 removed

modified:src/terminal.go+11 added-1 removed
4338 unmodified lines
4339 }43404341 var fillRet tui.FillReturn4342 wrap := t.activePreviewOpts.wrap4343 printWrapSign := func() {4344 if t.pwindow.CFill(tui.ColPreview.Fg(), tui.ColPreview.Bg(), -1, tui.Dim, t.wrapSign) == tui.FillNextLine {4345 t.pwindow.Move(t.pwindow.Y()-1, t.pwindow.Width())4346 }4347 fillRet = tui.FillContinue4348 }4349 for subIdx, subLine := range subLines {4350 // Render wrap sign for continuation sub-lines4351 if subIdx > 0 {4352 if fillRet == tui.FillContinue {
2 unmodified lines
4355 t.previewed.filled = true4356 break Loop4357 }4358 }4353 t.pwindow.CFill(tui.ColPreview.Fg(), tui.ColPreview.Bg(), -1, tui.Dim, t.wrapSign)4359 printWrapSign()4360 }43614362 prefixWidth := t.pwindow.X()4363 var url *url4364 _, _, ansi = extractColor(subLine, ansi, func(str string, ansi *ansiState) bool {4365 if fillRet == tui.FillNextLine {4366 printWrapSign()4367 prefixWidth = t.pwindow.X()4368 }4369 trimmed := []rune(str)4370 isTrimmed := false4371 if !wrap {4372 trimmed, isTrimmed = t.trimRight(trimmed, maxWidth-t.pwindow.X())
3276 unmodified lines
modified:test/test_preview.rb+27 added
580 unmodified lines
581 assert lines.any_include?('[1 2/1]')582 assert_equal 1, lines.match_count583 end584 end585586 def test_preview_wrap_sign_between_ansi_fragments587 tmux.send_keys %(seq 1 | #{FZF} --preview 'echo -e "\\x1b[33m1234567890 \\x1b[mhello"; echo -e "\\x1b[33m1234567890 \\x1b[mhello"' --preview-window 10,wrap-word), :Enter588 tmux.until do |lines|589 assert_equal 1, lines.match_count590 assert_equal 2, lines.count { |line| line.include?('│ 1234567890 │') }591 assert_equal 2, lines.count { |line| line.include?('│ ↳ hello │') }592 end593 end594595 def test_preview_wrap_sign_between_ansi_fragments_overflow596 tmux.send_keys %(seq 1 | #{FZF} --preview 'echo -e "\\x1b[33m1234567890 \\x1b[mhello"; echo -e "\\x1b[33m1234567890 \\x1b[mhello"' --preview-window 2,wrap-word), :Enter597 tmux.until do |lines|598 assert_equal 1, lines.match_count599 assert_equal 2, lines.count { |line| line.include?('│ 12 │') }600 assert_equal 0, lines.count { |line| line.include?('│ h') }601 end602 end603604 def test_preview_wrap_sign_between_ansi_fragments_overflow2605 tmux.send_keys %(seq 1 | #{FZF} --preview 'echo -e "\\x1b[33m1234567890 \\x1b[mhello"; echo -e "\\x1b[33m1234567890 \\x1b[mhello"' --preview-window 1,wrap-word), :Enter606 tmux.until do |lines|607 assert_equal 1, lines.match_count608 assert_equal 2, lines.count { |line| line.include?('│ 1 │') }609 assert_equal 0, lines.count { |line| line.include?('│ h') }610 end611 end612end