Skip to content
Myr

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

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

fix #4593 * test(core): add test for --freeze-right with long ellipsis

authored by LangLangBart · committed by GitHub · parent 2ab923f · Browse files · 2 files+11 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+11 added−1 removed

  • tests:+10 added−0 removed
  • other:+1 added−1 removed

2 files+11 added−1 removed

modified:src/terminal.go+1 added-1 removed
3805 unmodified lines
3806 offs[idx].offset[0] = util.Min32(offset.offset[0], int32(maxWidth-len(ellipsis)))3807 offs[idx].offset[1] = util.Min32(offset.offset[1], int32(maxWidth))3808 }3809 }3810 displayWidth = t.displayWidthWithLimit(runes, 0, displayWidth)3810 displayWidth = t.displayWidthWithLimit(runes, 0, maxWidth)3811 }3812 displayWidthSum += displayWidth38133814 if maxWidth > 0 {
3563 unmodified lines
modified:test/test_core.rb+10 added
1233 unmodified lines
1234 assert_equal(1, lines[-3].scan('XX').size)1235 end1236 end12371238 def test_freeze_right_with_ellipsis_and_scrolling1239 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", :Enter1240 tmux.until { |lines| assert_equal ' 100/100', lines[-2] }1241 tmux.send_keys(*Array.new(6) { :a })1242 tmux.until do |lines|1243 assert_match(/> 777g+$/, lines[-3])1244 assert_equal 1, lines.count { |l| l.end_with?('g') }1245 end1246 end12471248 def test_backward_eof1249 tmux.send_keys "echo foo | #{FZF} --bind 'backward-eof:reload(seq 100)'", :Enter1250 tmux.until { |lines| lines.item_count == 1 && lines.match_count == 1 }1251 tmux.send_keys 'x'
907 unmodified lines