From 60b35e748be4da4e3761f30081afd347d05928a0 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sat, 15 Nov 2025 11:36:56 +0900 Subject: [PATCH] Header and footer should not be wider than the list Example: WIDE=$(printf 'x%.0s' {1..1000}) (echo $WIDE; echo $WIDE) | fzf --header-lines 1 --style full --ellipsis XX --header "$WIDE" \ --no-header-lines-border --footer "$WIDE" --no-footer-border --- src/terminal.go | 8 +++++++- test/test_layout.rb | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/terminal.go b/src/terminal.go index 21d76225..e450d657 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -2490,6 +2490,8 @@ func (t *Terminal) resizeWindows(forcePreview bool, redrawBorder bool) { if shape.HasRight() { width++ } + // Make sure that the width does not exceed the list width + width = util.Min(t.window.Width()+t.headerIndentImpl(0, shape), width) height := b.Height() - borderLines(shape) return t.tui.NewWindow(top, left, width, height, windowType, noBorder, true) } @@ -3107,7 +3109,11 @@ func (t *Terminal) printFooter() { } func (t *Terminal) headerIndent(borderShape tui.BorderShape) int { - indentSize := t.pointerLen + t.markerLen + return t.headerIndentImpl(t.pointerLen+t.markerLen, borderShape) +} + +func (t *Terminal) headerIndentImpl(base int, borderShape tui.BorderShape) int { + indentSize := base if t.listBorderShape.HasLeft() { indentSize += 1 + t.borderWidth } diff --git a/test/test_layout.rb b/test/test_layout.rb index 56d944cf..bfe11e39 100644 --- a/test/test_layout.rb +++ b/test/test_layout.rb @@ -1215,6 +1215,15 @@ class TestLayout < TestInteractive end end + def test_header_and_footer_should_not_be_wider_than_list + tmux.send_keys %(WIDE=$(printf 'x%.0s' {1..1000}); (echo $WIDE; echo $WIDE) | fzf --header-lines 1 --style full --header-border bottom --header-lines-border top --ellipsis XX --header "$WIDE" --footer "$WIDE" --no-footer-border), :Enter + tmux.until do |lines| + matches = lines.filter_map { |line| line[/x+XX/] } + assert_equal 4, matches.length + assert_equal 1, matches.uniq.length + end + end + def test_combinations skip unless ENV['LONGTEST']