Compare commits

...

3 commits

Author SHA1 Message Date
Junegunn Choi
bf4869b7fa
[vim] Create popup terminal at its final size
Vim created the terminal at the current window size and resized it at the
next redraw. On Windows, fzf missed the resize when that redraw was delayed
and kept its initial layout.

Patch suggested by @FanXiangTM

Fix #4957
2026-11-19 23:09:03 +09:00
Adam Quinn Snow
eea2081857
Fix prompt overwrite with zero input and a one-line picker
An empty picker using adaptive height and inline info can be one row tall when
there is no input. Initialization emitted ESC[0A, which terminals interpret as
moving up one row, overwriting the preceding line.

Skip the cursor-up escape when no upward movement is needed.

Test is in test/test_layout.rb. Manual repro is easy with:

```
printf 'KEEP THIS LINE\n'; env FZF_DEFAULT_OPTS= FZF_DEFAULT_OPTS_FILE= \
    fzf --style=minimal --height='~50%' --info=inline-right </dev/null
```

Before the fix, KEEP THIS LINE disappears. Afterward, it remains above the picker.

Fix #4958
2026-11-19 22:58:49 +09:00
Junegunn Choi
4499615fe9
Fix --info inline-right:PREFIX not clearing previous output (#4954)
Close #4953
2026-11-12 10:51:45 +09:00
6 changed files with 36 additions and 2 deletions

View file

@ -1,6 +1,12 @@
CHANGELOG
=========
0.75.1
------
- Fixed `--info inline-right:PREFIX` leaving part of the previous output when the info gets shorter (#4953)
- Fixed a one-line picker overwriting the line above it, e.g. `--height=~50%` with inline info and empty input (#4958) (@nhooyr)
- [vim] Fixed the popup window being cropped on Windows when the first redraw after starting the terminal is delayed (#4957) (@FanXiangTM)
0.75.0
------
- Added `{change,transform,bg-transform}-info-command` actions (#4951) (@casperdcl)

View file

@ -1124,6 +1124,10 @@ function! s:execute_term(dict, command, temps) abort
endif
if is_popup
let term_opts.hidden = 1
" Avoid resizing the terminal after fzf starts (#4957)
let bounds = s:popup_bounds()
let term_opts.term_rows = bounds.height
let term_opts.term_cols = bounds.width
else
let term_opts.curwin = 1
endif

View file

@ -3664,7 +3664,10 @@ func (t *Terminal) printInfoImpl() {
pos++
}
} else {
pos = max(pos, t.window.Width()-outputLen-util.StringWidth(t.infoPrefix)-1)
move(line, pos, false)
newPos := max(pos, t.window.Width()-outputLen-util.StringWidth(t.infoPrefix)-1)
t.window.Print(strings.Repeat(" ", newPos-pos))
pos = newPos
printInfoPrefix()
}
}

View file

@ -292,7 +292,10 @@ func (r *LightRenderer) Init() error {
}
r.enableModes()
r.csi(fmt.Sprintf("%dA", r.MaxY()-1))
// CSI 0 A means one row up, not zero rows.
if height := r.MaxY(); height > 1 {
r.csi(fmt.Sprintf("%dA", height-1))
}
r.csi("G")
r.csi("K")
if !r.clearOnExit && !r.fullscreen {

View file

@ -1792,6 +1792,13 @@ class TestCore < TestInteractive
tmux.until { assert_match(%r{ 0/100000}, it[-1]) }
end
def test_info_inline_right_prefix_clearance
tmux.send_keys "seq 100000 | #{FZF} --info 'inline-right:xx '", :Enter
tmux.until { assert_match(%r{xx 100000/100000}, it[-1]) }
tmux.send_keys 'x'
tmux.until { assert_match(%r{ xx 0/100000}, it[-1]) }
end
def test_info_command
tmux.send_keys(%(seq 10000 | #{FZF} --separator x --info-command 'echo -e "--\\x1b[33m$FZF_POS\\x1b[m/$FZF_INFO--"'), :Enter)
tmux.until { assert_match(%r{^ --1/10000/10000-- xx}, it[-2]) }

View file

@ -187,6 +187,17 @@ class TestLayout < TestInteractive
tmux.until { assert_block(expected, it) }
end
def test_height_range_empty_input_preserves_previous_line
tmux.send_keys %(printf 'KEEP THIS LINE\\n'; : | FZF_DEFAULT_OPTS_FILE= #{FZF} --style=minimal --height='~50%' --info=inline-right), :Enter
tmux.until do |lines|
assert_match(%r{0/0}, lines.last)
assert_equal 'KEEP THIS LINE', lines[-2]
end
tmux.send_keys 'C-c'
tmux.until { |lines| assert_equal 'KEEP THIS LINE', lines.last }
end
def test_height_range_fit_preview_above
tmux.send_keys 'seq 3 | fzf --height ~100% --info=inline --border rounded --preview-window border-rounded --preview "seq {}" --preview-window up,60%', :Enter
expected = <<~OUTPUT