mirror of
https://github.com/junegunn/fzf.git
synced 2026-08-12 19:07:00 +08:00
Fix missing wrap sign at ANSI color boundary
This commit is contained in:
+11
-1
@@ -4340,6 +4340,12 @@ Loop:
|
|||||||
|
|
||||||
var fillRet tui.FillReturn
|
var fillRet tui.FillReturn
|
||||||
wrap := t.activePreviewOpts.wrap
|
wrap := t.activePreviewOpts.wrap
|
||||||
|
printWrapSign := func() {
|
||||||
|
if t.pwindow.CFill(tui.ColPreview.Fg(), tui.ColPreview.Bg(), -1, tui.Dim, t.wrapSign) == tui.FillNextLine {
|
||||||
|
t.pwindow.Move(t.pwindow.Y()-1, t.pwindow.Width())
|
||||||
|
}
|
||||||
|
fillRet = tui.FillContinue
|
||||||
|
}
|
||||||
for subIdx, subLine := range subLines {
|
for subIdx, subLine := range subLines {
|
||||||
// Render wrap sign for continuation sub-lines
|
// Render wrap sign for continuation sub-lines
|
||||||
if subIdx > 0 {
|
if subIdx > 0 {
|
||||||
@@ -4350,12 +4356,16 @@ Loop:
|
|||||||
break Loop
|
break Loop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t.pwindow.CFill(tui.ColPreview.Fg(), tui.ColPreview.Bg(), -1, tui.Dim, t.wrapSign)
|
printWrapSign()
|
||||||
}
|
}
|
||||||
|
|
||||||
prefixWidth := t.pwindow.X()
|
prefixWidth := t.pwindow.X()
|
||||||
var url *url
|
var url *url
|
||||||
_, _, ansi = extractColor(subLine, ansi, func(str string, ansi *ansiState) bool {
|
_, _, ansi = extractColor(subLine, ansi, func(str string, ansi *ansiState) bool {
|
||||||
|
if fillRet == tui.FillNextLine {
|
||||||
|
printWrapSign()
|
||||||
|
prefixWidth = t.pwindow.X()
|
||||||
|
}
|
||||||
trimmed := []rune(str)
|
trimmed := []rune(str)
|
||||||
isTrimmed := false
|
isTrimmed := false
|
||||||
if !wrap {
|
if !wrap {
|
||||||
|
|||||||
@@ -582,4 +582,31 @@ class TestPreview < TestInteractive
|
|||||||
assert_equal 1, lines.match_count
|
assert_equal 1, lines.match_count
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_preview_wrap_sign_between_ansi_fragments
|
||||||
|
tmux.send_keys %(seq 1 | #{FZF} --preview 'echo -e "\\x1b[33m1234567890 \\x1b[mhello"; echo -e "\\x1b[33m1234567890 \\x1b[mhello"' --preview-window 10,wrap-word), :Enter
|
||||||
|
tmux.until do |lines|
|
||||||
|
assert_equal 1, lines.match_count
|
||||||
|
assert_equal 2, lines.count { |line| line.include?('│ 1234567890 │') }
|
||||||
|
assert_equal 2, lines.count { |line| line.include?('│ ↳ hello │') }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_preview_wrap_sign_between_ansi_fragments_overflow
|
||||||
|
tmux.send_keys %(seq 1 | #{FZF} --preview 'echo -e "\\x1b[33m1234567890 \\x1b[mhello"; echo -e "\\x1b[33m1234567890 \\x1b[mhello"' --preview-window 2,wrap-word), :Enter
|
||||||
|
tmux.until do |lines|
|
||||||
|
assert_equal 1, lines.match_count
|
||||||
|
assert_equal 2, lines.count { |line| line.include?('│ 12 │') }
|
||||||
|
assert_equal 0, lines.count { |line| line.include?('│ h') }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_preview_wrap_sign_between_ansi_fragments_overflow2
|
||||||
|
tmux.send_keys %(seq 1 | #{FZF} --preview 'echo -e "\\x1b[33m1234567890 \\x1b[mhello"; echo -e "\\x1b[33m1234567890 \\x1b[mhello"' --preview-window 1,wrap-word), :Enter
|
||||||
|
tmux.until do |lines|
|
||||||
|
assert_equal 1, lines.match_count
|
||||||
|
assert_equal 2, lines.count { |line| line.include?('│ 1 │') }
|
||||||
|
assert_equal 0, lines.count { |line| line.include?('│ h') }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user