Let inline sections take precedence over --header-first
Before adoption: this commit came in with the history the project adopted, so no landing records it.
--header-first previously was rejected with --header-border=inline or --header-lines-border=inline. Now, inline placement wins: an inline section stays inside the list frame, and --header-first only affects non-inline sections (mainly the main --header).
authored by Junegunn Choi · committed by Junegunn Choi · parent d247284 · Browse files · 4 files·+46 added−10 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+46 added−10 removed
- tests:+36 added−2 removed
- other:+10 added−8 removed
Provenance
- Commit
dd7a081- Tree
bc1e523- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
d247284
4 files changed+46 added−10 removed
modified:man/man1/fzf.1+5 added-4 removed
1105 unmodified lines1106 shape that has both top and bottom segments (rounded / sharp / bold /1107 double / block / thinblock / horizontal) and falls back to \fBline\fR1108 otherwise. When the list border also has side segments, the separator1109 joins them with T-junctions; \fBhorizontal\fR has no side borders, so the1110-separator is drawn without T-junction endpoints. Not compatible with1111-\fB\-\-header\-first\fR, and when \fB\-\-header\-lines\fR is also set1112-\fB\-\-header\-lines\-border\fR must also be \fBinline\fR.1110+separator is drawn without T-junction endpoints. Takes precedence over1111+\fB\-\-header\-first\fR (the section stays inside the list frame), and1112+when \fB\-\-header\-lines\fR is also set \fB\-\-header\-lines\-border\fR1113+must also be \fBinline\fR.1114 1115 .TP1116 .BI "\-\-header\-label" [=LABEL]1117 Label to print on the header border10 unmodified lines1128 a single separator line between the header lines and the list section.1129 \fBinline\fR style embeds the header lines inside the list border frame1130 with a horizontal separator; it requires a \fB\-\-list\-border\fR shape1131 that has both top and bottom segments, falls back to \fBline\fR1131-otherwise, and is not compatible with \fB\-\-header\-first\fR.1132+otherwise.1133 1134 .SS FOOTER1135 1136 .TP1152 unmodified linesmodified:src/options.go-3 removed
3617 unmodified lines3618 opts.InputBorderShape == tui.BorderInline ||3619 opts.Preview.border == tui.BorderInline {3620 return errors.New("inline border is only supported for --header-border, --header-lines-border, and --footer-border")3621 }3622- if opts.HeaderFirst && (opts.HeaderBorderShape == tui.BorderInline || opts.HeaderLinesShape == tui.BorderInline) {3623- return errors.New("--header-first is not compatible with --header-border=inline or --header-lines-border=inline")3624- }3622 if opts.HeaderBorderShape == tui.BorderInline &&3623 opts.HeaderLinesShape != tui.BorderInline &&3624 opts.HeaderLinesShape != tui.BorderUndefined &&3625 opts.HeaderLinesShape != tui.BorderNone {324 unmodified linesmodified:src/terminal.go+5 added-1 removed
2842 unmodified lines2843 }2844 2845 if hasInputWindow {2846 var btop int2847- if (hasHeaderWindow || hasHeaderLinesWindow) && t.headerFirst {2847+ // Inline sections live inside the list frame, so they don't participate2848+ // in --header-first repositioning; only non-inline sections do.2849+ hasNonInlineHeader := hasHeaderWindow && t.headerBorderShape != tui.BorderInline2850+ hasNonInlineHeaderLines := hasHeaderLinesWindow && headerLinesShape != tui.BorderInline2851+ if (hasNonInlineHeader || hasNonInlineHeaderLines) && t.headerFirst {2852 switch t.layout {2853 case layoutDefault:2854 btop = w.Top() + w.Height()2855 // If both headers are present, the header lines are displayed with the list5336 unmodified linesmodified:test/test_layout.rb+36 added-2 removed
1489 unmodified lines1490 "header separator inherited list-border attr: #{sep_row.inspect}")1491 tmux.send_keys 'Escape'1492 end1493 1494+ # Inline takes precedence over --header-first: the main header stays1495+ # inside the list frame instead of moving below the input.1496+ def test_inline_header_border_overrides_header_first1497+ tmux.send_keys %(seq 5 | #{FZF} --style full --header foo --header-first --header-border inline), :Enter1498+ tmux.until do |lines|1499+ foo_idx = lines.index { |l| l.match?(/\A│\s+foo\s+│\z/) }1500+ input_idx = lines.index { |l| l.match?(/\A│\s+>\s+\d+\/\d+\s+│\z/) }1501+ foo_idx && input_idx && foo_idx < input_idx1502+ end1503+ end1504+1505+ # With both sections present, --header-first still moves the main --header1506+ # below the input while --header-lines-border=inline keeps header-lines1507+ # inside the list frame.1508+ def test_inline_header_lines_with_header_first_and_main_header1509+ tmux.send_keys %(seq 5 | #{FZF} --style full --header foo --header-lines 1 --header-first --header-lines-border inline), :Enter1510+ tmux.until do |lines|1511+ one_idx = lines.index { |l| l.match?(/\A│\s+1\s+│\z/) }1512+ foo_idx = lines.index { |l| l.match?(/\A│\s+foo\s+│\z/) }1513+ input_idx = lines.index { |l| l.match?(/\A│\s+>\s+\d+\/\d+\s+│\z/) }1514+ one_idx && foo_idx && input_idx && one_idx < input_idx && input_idx < foo_idx1515+ end1516+ end1517+1518+ # With no main --header, --header-first previously repositioned1519+ # header-lines. Inline now takes precedence: header-lines stays inside1520+ # the list frame.1521+ def test_inline_header_lines_with_header_first_no_main_header1522+ tmux.send_keys %(seq 5 | #{FZF} --style full --header-lines 1 --header-first --header-lines-border inline), :Enter1523+ tmux.until do |lines|1524+ one_idx = lines.index { |l| l.match?(/\A│\s+1\s+│\z/) }1525+ input_idx = lines.index { |l| l.match?(/\A│\s+>\s+\d+\/\d+\s+│\z/) }1526+ one_idx && input_idx && one_idx < input_idx1527+ end1528+ end1529+1530 # Invalid inline combinations must be rejected at startup.1531 def test_inline_rejected_on_unsupported_options1532 [1533 ['--border=inline', 'inline border is only supported'],1534 ['--list-border=inline', 'inline border is only supported'],1535 ['--input-border=inline', 'inline border is only supported'],1536 ['--preview-window=border-inline --preview :', 'invalid preview window option: border-inline'],1501- ['--header-first --header-border=inline', '--header-first is not compatible'],1502- ['--header-first --header-lines-border=inline --header-lines=1', '--header-first is not compatible'],1537 ['--header-border=inline --header-lines-border=sharp --header-lines=1',1538 '--header-border=inline requires --header-lines-border to be inline or unset']1539 ].each do |args, expected|1540 output = `#{FZF} #{args} < /dev/null 2>&1`69 unmodified lines