m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-20 01:23:43 -05:00

fix(terminal): correct display width calculation with maxWidth (#4596)

fix #4593

* test(core): add test for --freeze-right with long ellipsis
This commit is contained in:
LangLangBart
2025-11-20 01:09:36 +01:00
committed by GitHub
parent 2ab923f3ae
commit 3db63f5e52
2 changed files with 11 additions and 1 deletions

View File

@@ -3807,7 +3807,7 @@ func (t *Terminal) printHighlighted(result Result, colBase tui.ColorPair, colMat
offs[idx].offset[1] = util.Min32(offset.offset[1], int32(maxWidth))
}
}
displayWidth = t.displayWidthWithLimit(runes, 0, displayWidth)
displayWidth = t.displayWidthWithLimit(runes, 0, maxWidth)
}
displayWidthSum += displayWidth

View File

@@ -1235,6 +1235,16 @@ class TestCore < TestInteractive
end
end
def test_freeze_right_with_ellipsis_and_scrolling
tmux.send_keys "{ seq 6; ruby -e 'print \"g\"*1000, \"\\n\"'; seq 8 100; } | #{FZF} --ellipsis='777' --freeze-right 1 --scroll-off 0 --bind a:offset-up", :Enter
tmux.until { |lines| assert_equal ' 100/100', lines[-2] }
tmux.send_keys(*Array.new(6) { :a })
tmux.until do |lines|
assert_match(/> 777g+$/, lines[-3])
assert_equal 1, lines.count { |l| l.end_with?('g') }
end
end
def test_backward_eof
tmux.send_keys "echo foo | #{FZF} --bind 'backward-eof:reload(seq 100)'", :Enter
tmux.until { |lines| lines.item_count == 1 && lines.match_count == 1 }