From 1afd14381079a35eac0a4c2a5cacb86e2a3f476b Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Fri, 8 Aug 2025 18:51:24 +0900 Subject: [PATCH] Fix incorrect truncation of --info-command with --info=inline-right Fix #4479 --- src/terminal.go | 2 +- test/test_core.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/terminal.go b/src/terminal.go index 0fd5d006..dafd5f87 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -1394,7 +1394,7 @@ func (t *Terminal) ansiLabelPrinter(str string, color *tui.ColorPair, fill bool) if !fill { ellipsis, ellipsisWidth = util.Truncate(t.ellipsis, limit) } - if length > limit-ellipsisWidth { + if length > limit { trimmedRunes, _ := t.trimRight(runes, limit-ellipsisWidth) window.CPrint(*color, string(trimmedRunes)+string(ellipsis)) } else if fill { diff --git a/test/test_core.rb b/test/test_core.rb index d77bbcce..0b6d5db5 100644 --- a/test/test_core.rb +++ b/test/test_core.rb @@ -1415,6 +1415,11 @@ class TestCore < TestInteractive tmux.until { assert_match(%r{ --1/10000/10000-- *$}, it[-1]) } end + def test_info_command_inline_right_no_ansi + tmux.send_keys(%(seq 10000 | #{FZF} --info-command 'echo -e "--$FZF_POS/$FZF_INFO--"' --info inline-right), :Enter) + tmux.until { assert_match(%r{ --1/10000/10000-- *$}, it[-1]) } + end + def test_info_command_and_focus tmux.send_keys(%(seq 100 | #{FZF} --separator x --info-command 'echo $FZF_POS' --bind focus:clear-query), :Enter) tmux.until { assert_match(/^ 1 xx/, it[-2]) }