mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-24 08:53:50 -07:00
@@ -1235,9 +1235,14 @@ func (t *Terminal) ansiLabelPrinter(str string, color *tui.ColorPair, fill bool)
|
|||||||
return nil, 0
|
return nil, 0
|
||||||
}
|
}
|
||||||
printFn := func(window tui.Window, limit int) {
|
printFn := func(window tui.Window, limit int) {
|
||||||
if length > limit {
|
ellipsis := []rune{}
|
||||||
trimmedRunes, _ := t.trimRight(runes, limit)
|
ellipsisWidth := 0
|
||||||
window.CPrint(*color, string(trimmedRunes))
|
if !fill {
|
||||||
|
ellipsis, ellipsisWidth = util.Truncate(t.ellipsis, limit)
|
||||||
|
}
|
||||||
|
if length > limit-ellipsisWidth {
|
||||||
|
trimmedRunes, _ := t.trimRight(runes, limit-ellipsisWidth)
|
||||||
|
window.CPrint(*color, string(trimmedRunes)+string(ellipsis))
|
||||||
} else if fill {
|
} else if fill {
|
||||||
window.CPrint(*color, util.RepeatToFill(text, length, limit))
|
window.CPrint(*color, util.RepeatToFill(text, length, limit))
|
||||||
} else {
|
} else {
|
||||||
|
@@ -992,6 +992,36 @@ class TestLayout < TestInteractive
|
|||||||
tmux.until { assert_block(block, it) }
|
tmux.until { assert_block(block, it) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_label_trunction
|
||||||
|
command = <<~CMD
|
||||||
|
seq 10 | #{FZF} --style full --border --header-lines=1 --preview ':' \\
|
||||||
|
--border-label "#{'b' * 1000}" \\
|
||||||
|
--preview-label "#{'p' * 1000}" \\
|
||||||
|
--header-label "#{'h' * 1000}" \\
|
||||||
|
--header-label "#{'h' * 1000}" \\
|
||||||
|
--input-label "#{'i' * 1000}" \\
|
||||||
|
--list-label "#{'l' * 1000}"
|
||||||
|
CMD
|
||||||
|
writelines(command.lines.map(&:chomp))
|
||||||
|
tmux.send_keys("sh #{tempname}", :Enter)
|
||||||
|
tmux.until do |lines|
|
||||||
|
text = lines.join
|
||||||
|
assert_includes text, 'b··'
|
||||||
|
assert_includes text, 'l··p'
|
||||||
|
assert_includes text, 'p··'
|
||||||
|
assert_includes text, 'h··'
|
||||||
|
assert_includes text, 'i··'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_separator_no_ellipsis
|
||||||
|
tmux.send_keys %(seq 10 | #{FZF} --separator "$(seq 1000 | tr '\\n' ' ')"), :Enter
|
||||||
|
tmux.until do |lines|
|
||||||
|
assert_equal 10, lines.match_count
|
||||||
|
refute_includes lines.join, '··'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_header_border_no_pointer_and_marker
|
def test_header_border_no_pointer_and_marker
|
||||||
tmux.send_keys %(seq 10 | #{FZF} --header-lines 1 --header-border sharp --no-list-border --pointer '' --marker ''), :Enter
|
tmux.send_keys %(seq 10 | #{FZF} --header-lines 1 --header-border sharp --no-list-border --pointer '' --marker ''), :Enter
|
||||||
block = <<~BLOCK
|
block = <<~BLOCK
|
||||||
|
Reference in New Issue
Block a user