From eea208185723826d55702572249de7d6296aa5ee Mon Sep 17 00:00:00 2001 From: Adam Quinn Snow Date: Thu, 19 Nov 2026 03:55:45 -0700 Subject: [PATCH] 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 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