Fix --info inline-right not properly clearing the previous output

(seq 100000; sleep 1) | fzf --info inline-right --bind load:change-query:x
This commit is contained in:
Junegunn Choi 2024-05-03 11:56:54 +09:00
parent dba1644518
commit f6aa28c380
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
2 changed files with 11 additions and 2 deletions

View File

@ -1715,9 +1715,11 @@ func (t *Terminal) printInfo() {
if t.infoStyle == infoInlineRight {
if len(t.infoPrefix) == 0 {
pos = util.Max(pos, t.window.Width()-util.StringWidth(output)-3)
if pos < t.window.Width() {
t.move(line, pos, false)
newPos := util.Max(pos, t.window.Width()-util.StringWidth(output)-3)
t.window.Print(strings.Repeat(" ", newPos-pos))
pos = newPos
if pos < t.window.Width() {
printSpinner()
pos++
}

View File

@ -2970,6 +2970,13 @@ class TestGoFZF < TestBase
tmux.until { assert_match(%r{[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏] 100/100}, _1[-1]) }
end
def test_info_inline_right_clearance
tmux.send_keys "seq 100000 | #{FZF} --info inline-right", :Enter
tmux.until { assert_match(%r{100000/100000}, _1[-1]) }
tmux.send_keys 'x'
tmux.until { assert_match(%r{ 0/100000}, _1[-1]) }
end
def test_prev_next_selected
tmux.send_keys 'seq 10 | fzf --multi --bind ctrl-n:next-selected,ctrl-p:prev-selected', :Enter
tmux.until { |lines| assert_equal 10, lines.item_count }