From 1986d101e041a2a70139fc1369a786929a9f17e4 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 19 Apr 2026 22:24:30 +0900 Subject: [PATCH] Redraw when change-header changes line count The inline header slot's row budget depends on header content length, but resizeIfNeeded() tolerates a shorter-than-wanted inline window, so the stale slot stays. Drive a redraw on length change to re-run the layout. --- src/terminal.go | 12 +++++++++--- test/test_layout.rb | 13 +++++++++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/terminal.go b/src/terminal.go index ed9245c8..a4c310c3 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -6781,10 +6781,16 @@ func (t *Terminal) Loop() error { t.cx = len(t.input) case actChangeHeader, actTransformHeader, actBgTransformHeader: capture(false, func(header string) { - // When a dedicated header window is not used, we may need to - // update other elements as well. if t.changeHeader(header) { - req(reqList, reqPrompt, reqInfo) + // resizeIfNeeded() tolerates a shorter-than-wanted inline + // window, so a length change can leave the inline slot + // stale. Force a redraw to re-run the layout. Non-inline + // shapes are handled by resizeIfNeeded. + if t.headerBorderShape == tui.BorderInline { + req(reqRedraw) + } else { + req(reqList, reqPrompt, reqInfo) + } } req(reqHeader) }) diff --git a/test/test_layout.rb b/test/test_layout.rb index c4165c42..429de28d 100644 --- a/test/test_layout.rb +++ b/test/test_layout.rb @@ -1527,6 +1527,19 @@ class TestLayout < TestInteractive end end + # Regression: with --header-border=inline and --header-lines but no + # --header, the inline slot was sized for header-lines only. After + # change-header added a main header line, resizeIfNeeded tolerated the + # too-small slot, so the header-lines line got displaced and disappeared. + def test_inline_change_header_grows_slot + tmux.send_keys %(seq 5 | #{FZF} --style full --header-lines 1 --header-border inline --bind space:change-header:tada), :Enter + tmux.until { |lines| lines.any_include?(/\A│\s+1\s+│\z/) } + tmux.send_keys ' ' + tmux.until do |lines| + lines.any_include?(/\A│\s+1\s+│\z/) && lines.any_include?(/\A│\s+tada\s+│\z/) + end + end + # Invalid inline combinations must be rejected at startup. def test_inline_rejected_on_unsupported_options [