diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d2dcde4..6ab73874 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ 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) 0.75.0 ------ diff --git a/src/tui/light.go b/src/tui/light.go index b8c6ac7a..c8f254ae 100644 --- a/src/tui/light.go +++ b/src/tui/light.go @@ -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 { diff --git a/test/test_layout.rb b/test/test_layout.rb index a9075bc1..72e5e901 100644 --- a/test/test_layout.rb +++ b/test/test_layout.rb @@ -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