Display header lines at the top in 'reverse-list' layout
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Junegunn Choi · committed by Junegunn Choi · parent e84afe1 · Browse files · 5 files·+189 added−97 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+189 added−97 removed
- tests:+122 added−67 removed
- other:+67 added−30 removed
Provenance
- Commit
18cbb4a- Tree
0eb142e- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
e84afe1
5 files changed+189 added−97 removed
modified:src/options.go+8 added-1 removed
3108 unmodified lines3109 3110 if opts.HeaderLinesShape == tui.BorderNone {3111 opts.HeaderLinesShape = tui.BorderPhantom3112 } else if opts.HeaderLinesShape == tui.BorderUndefined {3113+ // In reverse-list layout, header lines should be at the top, while3114+ // ordinary header should be at the bottom. So let's use a separate3115+ // window for the header lines.3116+ if opts.Layout == layoutReverseList {3117+ opts.HeaderLinesShape = tui.BorderPhantom3118+ } else {3113- opts.HeaderLinesShape = tui.BorderNone3119+ opts.HeaderLinesShape = tui.BorderNone3120+ }3121 }3122 3123 if opts.Pointer == nil {3124 defaultPointer := "▌"276 unmodified linesmodified:src/terminal.go+58 added-29 removed
1136 unmodified lines1137 }1138 return t.visibleHeaderLines()1139 }1140 1141+func (t *Terminal) visibleInputLinesInList() int {1142+ if t.inputWindow != nil || t.inputless {1143+ return 01144+ }1145+ if t.noSeparatorLine() {1146+ return 11147+ }1148+ return 21149+}1150+1151 // Extra number of lines needed to display fzf1152 func (t *Terminal) extraLines() int {1153 extra := 01154 if !t.inputless {671 unmodified lines1826 1827 headerLinesHeight := 01828 if hasHeaderLinesWindow {1829 headerLinesHeight = util.Min(availableLines, borderLines(t.headerLinesShape)+t.headerLines)1820- if t.layout == layoutReverse {1830+ if t.layout != layoutDefault {1831 shift += headerLinesHeight1832 shrink += headerLinesHeight1833 } else {1834 shrink += headerLinesHeight252 unmodified lines2087 var btop int2088 if hasHeaderWindow && t.headerFirst {2089 if t.layout == layoutReverse {2090 btop = w.Top() - inputBorderHeight - headerLinesHeight2091+ } else if t.layout == layoutReverseList {2092+ btop = w.Top() + w.Height()2093 } else {2094 btop = w.Top() + w.Height() + headerLinesHeight2095 }2096 } else {2097 if t.layout == layoutReverse {2098 btop = w.Top() - shrink2099+ } else if t.layout == layoutReverseList {2100+ btop = w.Top() + w.Height() + headerBorderHeight2101 } else {2102 btop = w.Top() + w.Height() + headerBorderHeight + headerLinesHeight2103 }2104 }20 unmodified lines2125 var btop int2126 if hasInputWindow && t.headerFirst {2127 if t.layout == layoutReverse {2128 btop = w.Top() - shrink2129+ } else if t.layout == layoutReverseList {2130+ btop = w.Top() + w.Height() + inputBorderHeight2131 } else {2132 btop = w.Top() + w.Height() + inputBorderHeight + headerLinesHeight2133 }2134 } else {2135 if t.layout == layoutReverse {2136 btop = w.Top() - headerBorderHeight - headerLinesHeight2137+ } else if t.layout == layoutReverseList {2138+ btop = w.Top() + w.Height()2139 } else {2140 btop = w.Top() + w.Height() + headerLinesHeight2141 }2142 }7 unmodified lines2150 2151 // Set up header lines border2152 if hasHeaderLinesWindow {2153 var btop int2136- if t.layout == layoutReverse {2154+ if t.layout != layoutDefault {2155 btop = w.Top() - headerLinesHeight2156 } else {2157 btop = w.Top() + w.Height()2158 }53 unmodified lines2212 switch t.layout {2213 case layoutDefault:2214 y = h - y - 12215 case layoutReverseList:2198- n := t.visibleHeaderLinesInList()2199- if !t.inputless {2200- n++2201- }2202- if !t.noSeparatorLine() {2203- n++2204- }2205- if y < n {2216+ if t.window == t.inputWindow || t.window == t.headerWindow {2217+ // From bottom to top2218 y = h - y - 12219 } else {2220+ /*2221+ * List 12222+ * List 22223+ * Header 12224+ * Header 22225+ * Input 22226+ * Input 12227+ */2228+ i := t.visibleInputLinesInList()2229+ n := t.visibleHeaderLinesInList()2230+ if i > 0 && y < i {2231+ y = h - y - 12232+ } else if n > 0 && y < i+n {2233+ y = h - y - 12234+ } else {2235+ // Top to bottom2208- y -= n2236+ y -= n + i2237+ }2238 }2239 }2240 2241 if clear {1931 unmodified lines4173 func (t *Terminal) addClickHeaderWord(env []string) []string {4174 /*4175 * echo $'HL1\nHL2' | fzf --header-lines 3 --header $'H1\nH2' --header-lines-border --bind 'click-header:preview:env | grep FZF_CLICK'4176 *4148- * REVERSE DEFAULT4149- * H1 1 14150- * H2 2 HL2 24151- * ------- HL1 34152- * HL1 3 -------4153- * HL2 4 H1 44154- * 5 H2 54177+ * REVERSE DEFAULT REVERSE-LIST4178+ * H1 1 1 HL1 14179+ * H2 2 HL2 2 HL2 24180+ * ------- HL1 3 34181+ * HL1 3 ------- -------4182+ * HL2 4 H1 4 H1 44183+ * 5 H2 5 H2 54184 */4185 lineNum := t.clickHeaderLine - 14186 if lineNum < 0 {4187 // Never clicked on the header4188 return env4189 }4190 4191+ // NOTE: t.header is padded with empty strings so that its size is equal to t.headerLines4192 var line string4193+ headers := [2][]string{t.header, t.header0}4194 if t.layout == layoutReverse {4164- if lineNum < len(t.header0) {4165- line = t.header0[lineNum]4166- } else if lineNum-len(t.header0) < len(t.header) {4167- line = t.header[lineNum-len(t.header0)]4195+ headers[0], headers[1] = headers[1], headers[0]4196+ }4197+ if lineNum < len(headers[0]) {4198+ index := lineNum4199+ if t.layout == layoutDefault {4200+ index = len(headers[0]) - index - 14201 }4169- } else {4170- // NOTE: t.header is padded with empty strings so that its size is equal to t.headerLines4171- if lineNum < len(t.header) {4172- line = t.header[len(t.header)-lineNum-1]4173- } else if lineNum-len(t.header) < len(t.header0) {4174- line = t.header0[lineNum-len(t.header)]4175- }4202+ line = headers[0][index]4203+ } else if lineNum-len(headers[0]) < len(headers[1]) {4204+ line = headers[1][lineNum-len(headers[0])]4205 }4206 if len(line) == 0 {4207 return env4208 }2015 unmodified linesmodified:test/test_core.rb+4 added-4 removed
574 unmodified lines575 def test_header_lines_reverse_list576 tmux.send_keys "seq 100 | #{fzf('--header-lines=10 -q 5 --layout=reverse-list')}", :Enter577 2.times do578 tmux.until do |lines|579- assert_equal '> 50', lines[0]580- assert_equal ' 2', lines[-4]581- assert_equal ' 1', lines[-3]579+ assert_equal ' 9', lines[8]580+ assert_equal ' 10', lines[9]581+ assert_equal '> 50', lines[10]582 assert_equal ' 18/90', lines[-2]583 end584 tmux.send_keys :Up585 end78 unmodified lines664 header = File.readlines(FILE, chomp: true).take(5)665 tmux.until do |lines|666 assert_equal ' 90/90', lines[-2]667 assert_equal header.map { |line| " #{line}".rstrip }, lines[-7...-2]668- assert_equal (' 1'..' 10').to_a.reverse, lines[-17...-7]668+ assert_equal (' 1'..' 10').to_a, lines.take(10)669 end670 end671 672 def test_cancel938 unmodified linesmodified:test/test_layout.rb+118 added-63 removed
4 unmodified lines5 # Test cases that mainly use assert_block to verify the layout of fzf6 class TestLayout < TestInteractive7 def assert_block(expected, lines)8 cols = expected.lines.map { it.chomp.length }.max9- top = lines.take(expected.lines.length).map { _1[0, cols].rstrip + "\n" }.join10- bottom = lines.reverse.take(expected.lines.length).reverse.map { _1[0, cols].rstrip + "\n" }.join11- assert_includes [top, bottom], expected9+ top = lines.take(expected.lines.length).map { it[0, cols].rstrip + "\n" }.join.chomp10+ bottom = lines.reverse.take(expected.lines.length).reverse.map { it[0, cols].rstrip + "\n" }.join.chomp11+ assert_includes [top, bottom], expected.chomp12 end13 14 def test_vanilla15 tmux.send_keys "seq 1 100000 | #{fzf}", :Enter2 unmodified lines18 > 119 100000/10000020 >21 BLOCK22- tmux.until { assert_block(block, _1) }22+ tmux.until { assert_block(block, it) }23 24 # Testing basic key bindings25 tmux.send_keys '99', 'C-a', '1', 'C-f', '3', 'C-b', 'C-h', 'C-u', 'C-e', 'C-y', 'C-k', 'Tab', 'BTab'26 block = <<~BLOCK1 unmodified line28 39129 856/10000030 > 39131 BLOCK32- tmux.until { assert_block(block, _1) }32+ tmux.until { assert_block(block, it) }33 34 tmux.send_keys :Enter35 assert_equal '3910', fzf_output36 end8 unmodified lines45 246 147 foobar48 OUTPUT49- tmux.until { assert_block(block, _1) }49+ tmux.until { assert_block(block, it) }50 end51 52 def test_header_first_reverse53 tmux.send_keys "seq 1000 | #{FZF} --header foobar --header-lines 3 --header-first --reverse --inline-info", :Enter4 unmodified lines58 359 > < 997/99760 > 461 OUTPUT62- tmux.until { assert_block(block, _1) }62+ tmux.until { assert_block(block, it) }63 end64 65 def test_change_and_transform_header66 [8 unmodified lines75 bar76 1/177 >78 OUTPUT79- tmux.until { assert_block(expected, _1) }79+ tmux.until { assert_block(expected, it) }80 tmux.send_keys :Space81 expected = <<~OUTPUT82 > 383 24 unmodified lines88 489 1/190 >91 OUTPUT92- tmux.until { assert_block(expected, _1) }92+ tmux.until { assert_block(expected, it) }93 next unless i.zero?94 95 teardown96 setup9 unmodified lines106 bar107 1/1108 >109 OUTPUT110- tmux.until { assert_block(expected, _1) }110+ tmux.until { assert_block(expected, it) }111 tmux.send_keys :Space112 expected = <<~OUTPUT113 > 3114 24 unmodified lines119 4120 1/1121 >122 OUTPUT123- tmux.until { assert_block(expected, _1) }123+ tmux.until { assert_block(expected, it) }124 end125 126 def test_reload_and_change_cache127 tmux.send_keys "echo bar | #{FZF} --bind 'zero:change-header(foo)+reload(echo foo)+clear-query'", :Enter1 unmodified line129 > bar130 1/1131 >132 OUTPUT133- tmux.until { assert_block(expected, _1) }133+ tmux.until { assert_block(expected, it) }134 tmux.send_keys :z135 expected = <<~OUTPUT136 > foo137 foo138 1/1139 >140 OUTPUT141- tmux.until { assert_block(expected, _1) }141+ tmux.until { assert_block(expected, it) }142 end143 144 def test_toggle_header145 tmux.send_keys "seq 4 | #{FZF} --header-lines 2 --header foo --bind space:toggle-header --header-first --height 10 --border rounded", :Enter8 unmodified lines154 │ 1155 │ foo156 ╰───────157 OUTPUT158- tmux.until { assert_block(before, _1) }158+ tmux.until { assert_block(before, it) }159 tmux.send_keys :Space160 after = <<~OUTPUT161 ╭───────162 │5 unmodified lines168 │ 2/2169 │ >170 ╰───────171 OUTPUT172- tmux.until { assert_block(after, _1) }172+ tmux.until { assert_block(after, it) }173 tmux.send_keys :Space174- tmux.until { assert_block(before, _1) }174+ tmux.until { assert_block(before, it) }175 end176 177 def test_height_range_fit178 tmux.send_keys 'seq 3 | fzf --height ~100% --info=inline --border rounded', :Enter4 unmodified lines183 │ > 1184 │ > < 3/3185 ╰──────────186 OUTPUT187- tmux.until { assert_block(expected, _1) }187+ tmux.until { assert_block(expected, it) }188 end189 190 def test_height_range_fit_preview_above191 tmux.send_keys 'seq 3 | fzf --height ~100% --info=inline --border rounded --preview-window border-rounded --preview "seq {}" --preview-window up,60%', :Enter10 unmodified lines202 │ > 1203 │ > < 3/3204 ╰──────────205 OUTPUT206- tmux.until { assert_block(expected, _1) }206+ tmux.until { assert_block(expected, it) }207 end208 209 def test_height_range_fit_preview_above_alternative210 tmux.send_keys 'seq 3 | fzf --height ~100% --border=sharp --preview "seq {}" --preview-window up,40%,border-bottom --padding 1 --exit-0 --header hello --header-lines=2', :Enter12 unmodified lines223 │ >224 │225 └─────────226 OUTPUT227- tmux.until { assert_block(expected, _1) }227+ tmux.until { assert_block(expected, it) }228 end229 230 def test_height_range_fit_preview_left231 tmux.send_keys "seq 3 | fzf --height ~100% --border=vertical --preview 'seq {}' --preview-window left,5,border-right --padding 1 --exit-0 --header $'hello\\nworld' --header-lines=2", :Enter7 unmodified lines239 │ │ 1/1 ─240 │ │ >241 │242 OUTPUT243- tmux.until { assert_block(expected, _1) }243+ tmux.until { assert_block(expected, it) }244 end245 246 def test_height_range_overflow247 tmux.send_keys 'seq 100 | fzf --height ~5 --info=inline --border rounded', :Enter3 unmodified lines251 │ > 1252 │ > < 100/100253 ╰──────────────254 OUTPUT255- tmux.until { assert_block(expected, _1) }255+ tmux.until { assert_block(expected, it) }256 end257 258 def test_no_extra_newline_issue_3209259 tmux.send_keys(%(seq 100 | #{FZF} --height 10 --preview-window up,wrap,border-rounded --preview 'printf "─%.0s" $(seq 1 "$((FZF_PREVIEW_COLUMNS - 5))"); printf $"\\e[7m%s\\e[0m" title; echo; echo something'), :Enter)8 unmodified lines268 > 1269 100/100 ─270 >271 OUTPUT272- tmux.until { assert_block(expected, _1) }272+ tmux.until { assert_block(expected, it) }273 end274 275 def test_fzf_multi_line276 tmux.send_keys %[(echo -en '0\\0'; echo -en '1\\n2\\0'; seq 1000) | fzf --read0 --multi --bind load:select-all --border rounded], :Enter8 unmodified lines285 │ 3/3 (3)286 │ >287 ╰───────────288 BLOCK289- tmux.until { assert_block(block, _1) }289+ tmux.until { assert_block(block, it) }290 tmux.send_keys :Up, :Up291 block = <<~BLOCK292 ╭───────293 │ >╻1294 │ >┃2295 │ >┃3296 BLOCK297- tmux.until { assert_block(block, _1) }297+ tmux.until { assert_block(block, it) }298 299 block = <<~BLOCK300 │ >┃301 │302 │ >303 ╰───304 BLOCK305- tmux.until { assert_block(block, _1) }305+ tmux.until { assert_block(block, it) }306 end307 308 def test_fzf_multi_line_reverse309 tmux.send_keys %[(echo -en '0\\0'; echo -en '1\\n2\\0'; seq 1000) | fzf --read0 --multi --bind load:select-all --border rounded --reverse], :Enter7 unmodified lines317 │ ╻1318 │ ┃2319 │ ┃3320 BLOCK321- tmux.until { assert_block(block, _1) }321+ tmux.until { assert_block(block, it) }322 end323 324 def test_fzf_multi_line_no_pointer_and_marker325 tmux.send_keys %[(echo -en '0\\0'; echo -en '1\\n2\\0'; seq 1000) | fzf --read0 --multi --bind load:select-all --border rounded --reverse --pointer '' --marker '' --marker-multi-line ''], :Enter7 unmodified lines333 │ 1334 │ 2335 │ 3336 BLOCK337- tmux.until { assert_block(block, _1) }337+ tmux.until { assert_block(block, it) }338 end339 340 def test_gap341 tmux.send_keys %(seq 100 | #{FZF} --gap --border --reverse), :Enter8 unmodified lines350 │ 3351 │ ┈┈┈┈┈┈┈┈┈┈┈┈┈┈352 │ 4353 BLOCK354- tmux.until { assert_block(block, _1) }354+ tmux.until { assert_block(block, it) }355 end356 357 def test_gap_2358 tmux.send_keys %(seq 100 | #{FZF} --gap=2 --gap-line xyz --border --reverse), :Enter8 unmodified lines367 │368 │ xyzxyzxyzxyzxy369 │ 3370 BLOCK371- tmux.until { assert_block(block, _1) }371+ tmux.until { assert_block(block, it) }372 end373 374 def test_list_border_and_label375 tmux.send_keys %(seq 100 | #{FZF} --border rounded --list-border double --list-label list --list-label-pos 2:bottom --header-lines 3 --query 1 --padding 1,2), :Enter8 unmodified lines384 │ ╚list══════385 │386 ╰──────────────387 BLOCK388- tmux.until { assert_block(block, _1) }388+ tmux.until { assert_block(block, it) }389 end390 391 def test_input_border_and_label392 tmux.send_keys %(seq 100 | #{FZF} --border rounded --input-border bold --input-label input --input-label-pos 2 --header-lines 3 --query 1 --padding 1,2), :Enter9 unmodified lines402 │ ┗━━━━━━━━━━403 │404 ╰──────────────405 BLOCK406- tmux.until { assert_block(block, _1) }406+ tmux.until { assert_block(block, it) }407 end408 409 def test_input_border_and_label_header_first410 tmux.send_keys %(seq 100 | #{FZF} --border rounded --input-border bold --input-label input --input-label-pos 2 --header-lines 3 --query 1 --padding 1,2 --header-first), :Enter9 unmodified lines420 │ 1421 │422 ╰──────────────423 BLOCK424- tmux.until { assert_block(block, _1) }424+ tmux.until { assert_block(block, it) }425 end426 427 def test_list_input_border_and_label428 tmux.send_keys %(14 unmodified lines443 │ ┗━━━━━━━━━━444 │445 ╰──────────────446 BLOCK447- tmux.until { assert_block(block, _1) }447+ tmux.until { assert_block(block, it) }448 tmux.send_keys :Space449 block = <<~BLOCK450 │ ║ 11451 │ ║ > 107 unmodified lines459 │ ┗━━━━━━━━━━460 │461 ╰──────────────462 BLOCK463- tmux.until { assert_block(block, _1) }463+ tmux.until { assert_block(block, it) }464 end465 466 def test_list_input_border_and_label_header_first467 tmux.send_keys %(14 unmodified lines482 │ 1483 │484 ╰──────────────485 BLOCK486- tmux.until { assert_block(block, _1) }486+ tmux.until { assert_block(block, it) }487 tmux.send_keys :Space488 block = <<~BLOCK489 │ ║ 11490 │ ║ > 107 unmodified lines498 │ 1499 │500 ╰──────────────501 BLOCK502- tmux.until { assert_block(block, _1) }502+ tmux.until { assert_block(block, it) }503 end504 505 def test_header_border_and_label506 tmux.send_keys %(seq 100 | #{FZF} --border rounded --header-lines 3 --header-border sharp --header-label header --header-label-pos 2:bottom --query 1 --padding 1,2), :Enter10 unmodified lines517 │ > 1518 │519 ╰────────────520 BLOCK521- tmux.until { assert_block(block, _1) }521+ tmux.until { assert_block(block, it) }522 end523 524 def test_header_border_toggle525 tmux.send_keys %(seq 100 | #{FZF} --list-border rounded --header-border rounded --bind 'space:change-header(hello),enter:change-header()'), :Enter6 unmodified lines532 │ 100/100 ─533 │ >534 ╰────────────535 BLOCK536- tmux.until { assert_block(block1, _1) }536+ tmux.until { assert_block(block1, it) }537 538 tmux.send_keys :Space539 block2 = <<~BLOCK540 │ 35 unmodified lines546 ╰────────────547 100/100 ─548 >549 BLOCK550- tmux.until { assert_block(block2, _1) }550+ tmux.until { assert_block(block2, it) }551 552 tmux.send_keys :Enter553- tmux.until { assert_block(block1, _1) }553+ tmux.until { assert_block(block1, it) }554 end555 556 def test_header_border_toggle_with_header_lines557 tmux.send_keys %(seq 100 | #{FZF} --list-border rounded --header-border rounded --bind 'space:change-header(hello),enter:change-header()' --header-lines 2), :Enter8 unmodified lines566 ╰──────────567 98/98 ─568 >569 BLOCK570- tmux.until { assert_block(block1, _1) }570+ tmux.until { assert_block(block1, it) }571 572 tmux.send_keys :Space573 block2 = <<~BLOCK574 │ 46 unmodified lines581 ╰──────────582 98/98 ─583 >584 BLOCK585- tmux.until { assert_block(block2, _1) }585+ tmux.until { assert_block(block2, it) }586 587 tmux.send_keys :Enter588- tmux.until { assert_block(block1, _1) }588+ tmux.until { assert_block(block1, it) }589 end590 591 def test_header_border_toggle_with_header_lines_header_first592 tmux.send_keys %(seq 100 | #{FZF} --list-border rounded --header-border rounded --bind 'space:change-header(hello),enter:change-header()' --header-lines 2 --header-first), :Enter8 unmodified lines601 │ 2602 │ 1603 ╰──────────604 BLOCK605- tmux.until { assert_block(block1, _1) }605+ tmux.until { assert_block(block1, it) }606 607 tmux.send_keys :Space608 block2 = <<~BLOCK609 │ 46 unmodified lines616 │ 1617 │ hello618 ╰──────────619 BLOCK620- tmux.until { assert_block(block2, _1) }620+ tmux.until { assert_block(block2, it) }621 622 tmux.send_keys :Enter623- tmux.until { assert_block(block1, _1) }623+ tmux.until { assert_block(block1, it) }624 end625 626 def test_header_border_toggle_with_header_lines_header_lines_border627 tmux.send_keys %(seq 100 | #{FZF} --list-border rounded --header-border rounded --bind 'space:change-header(hello),enter:change-header()' --header-lines 2 --header-lines-border double), :Enter8 unmodified lines636 ╚══════════637 98/98 ─638 >639 BLOCK640- tmux.until { assert_block(block1, _1) }640+ tmux.until { assert_block(block1, it) }641 642 tmux.send_keys :Space643 block2 = <<~BLOCK644 │ > 37 unmodified lines652 ╰──────────653 98/98 ─654 >655 BLOCK656- tmux.until { assert_block(block2, _1) }656+ tmux.until { assert_block(block2, it) }657 658 tmux.send_keys :Enter659- tmux.until { assert_block(block1, _1) }659+ tmux.until { assert_block(block1, it) }660 end661 662 def test_header_border_toggle_with_header_lines_header_first_header_lines_border663 tmux.send_keys %(seq 100 | #{FZF} --list-border rounded --header-border rounded --bind 'space:change-header(hello),enter:change-header()' --header-lines 2 --header-first --header-lines-border double), :Enter8 unmodified lines672 ╚══════════673 98/98 ─674 >675 BLOCK676- tmux.until { assert_block(block1, _1) }676+ tmux.until { assert_block(block1, it) }677 678 tmux.send_keys :Space679 block2 = <<~BLOCK680 │ > 37 unmodified lines688 ╭──────────689 │ hello690 ╰──────────691 BLOCK692- tmux.until { assert_block(block2, _1) }692+ tmux.until { assert_block(block2, it) }693 694 tmux.send_keys :Enter695- tmux.until { assert_block(block1, _1) }695+ tmux.until { assert_block(block1, it) }696 end697 698 def test_header_border_and_label_header_first699 tmux.send_keys %(seq 100 | #{FZF} --border rounded --header-lines 3 --header-border sharp --header-label header --header-label-pos 2:bottom --query 1 --padding 1,2 --header-first), :Enter10 unmodified lines710 │ └header──711 │712 ╰────────────713 BLOCK714- tmux.until { assert_block(block, _1) }714+ tmux.until { assert_block(block, it) }715 end716 717 def test_header_border_and_label_with_list_border718 tmux.send_keys %(seq 100 | #{FZF} --border rounded --list-border double --list-label list --list-label-pos 2:bottom --header-lines 3 --header-border sharp --header-label header --header-label-pos 2:bottom --query 1 --padding 1,2), :Enter11 unmodified lines730 │ > 1731 │732 ╰──────────────733 BLOCK734- tmux.until { assert_block(block, _1) }734+ tmux.until { assert_block(block, it) }735 end736 737 def test_header_border_and_label_with_list_border_header_first738 tmux.send_keys %(seq 100 | #{FZF} --border rounded --list-border double --list-label list --list-label-pos 2:bottom --header-lines 3 --header-border sharp --header-label header --header-label-pos 2:bottom --query 1 --padding 1,2 --header-first), :Enter11 unmodified lines750 │ └header────751 │752 ╰──────────────753 BLOCK754- tmux.until { assert_block(block, _1) }754+ tmux.until { assert_block(block, it) }755 end756 757 def test_all_borders758 tmux.send_keys %(seq 100 | #{FZF} --border rounded --list-border double --list-label list --list-label-pos 2:bottom --header-lines 3 --header-border sharp --header-label header --header-label-pos 2:bottom --query 1 --padding 1,2 --input-border bold --input-label input --input-label-pos 2:bottom), :Enter13 unmodified lines772 │ ┗input━━━━━773 │774 ╰──────────────775 BLOCK776- tmux.until { assert_block(block, _1) }776+ tmux.until { assert_block(block, it) }777 end778 779 def test_all_borders_header_first780 tmux.send_keys %(seq 100 | #{FZF} --border rounded --list-border double --list-label list --list-label-pos 2:bottom --header-lines 3 --header-border sharp --header-label header --header-label-pos 2:bottom --query 1 --padding 1,2 --input-border bold --input-label input --input-label-pos 2:bottom --header-first), :Enter13 unmodified lines794 │ └header────795 │796 ╰──────────────797 BLOCK798- tmux.until { assert_block(block, _1) }798+ tmux.until { assert_block(block, it) }799 end800 801 def test_style_full_adaptive_height802 tmux.send_keys %(seq 1| #{FZF} --style=full --height=~100% --header-lines=1 --info=default), :Enter7 unmodified lines810 │ 0/0811 │ >812 ╰────────813 BLOCK814- tmux.until { assert_block(block, _1) }814+ tmux.until { assert_block(block, it) }815 end816 817 def test_style_full_adaptive_height_double818 tmux.send_keys %(seq 1| #{FZF} --style=full:double --border --height=~100% --header-lines=1 --info=default), :Enter9 unmodified lines828 ║ ║ >829 ║ ╚════════830 ╚══════════831 BLOCK832- tmux.until { assert_block(block, _1) }832+ tmux.until { assert_block(block, it) }833 end834 835 def test_preview_window_noinfo836 # │ 1 ││18 unmodified lines855 │ │ >856 │ └─────857 └───────858 BLOCK859- tmux.until { assert_block(block, _1) }859+ tmux.until { assert_block(block, it) }860 end861 862 def test_min_height_auto863 tmux.send_keys %(seq 100 | #{FZF} --style full:sharp --height 1% --min-height 5+), :Enter9 unmodified lines873 ┌─────────874 │ >875 └─────────876 BLOCK877- tmux.until { assert_block(block, _1) }877+ tmux.until { assert_block(block, it) }878 end879 880 def test_min_height_auto_no_input881 tmux.send_keys %(seq 100 | #{FZF} --style full:sharp --no-input --height 1% --min-height 5+), :Enter6 unmodified lines888 │ 2889 │ > 1890 └─────────891 BLOCK892- tmux.until { assert_block(block, _1) }892+ tmux.until { assert_block(block, it) }893 end894 895 def test_min_height_auto_no_input_reverse_list896 tmux.send_keys %(seq 100 | #{FZF} --style full:sharp --layout reverse-list --no-input --height 1% --min-height 5+), :Enter6 unmodified lines903 │ 4904 │ 5905 └─────────906 BLOCK907- tmux.until { assert_block(block, _1) }907+ tmux.until { assert_block(block, it) }908 end909+910+ def test_layout_reverse_list911+ prefix = "seq 5 | #{FZF} --layout reverse-list --no-list-border --height ~100% --border sharp "912+ suffixes = [913+ %[],914+ %[--header "$(seq 101 103)"],915+ %[--header "$(seq 101 103)" --header-first],916+ %[--header "$(seq 101 103)" --header-lines 3],917+ %[--header "$(seq 101 103)" --header-lines 3 --header-first],918+ %[--header "$(seq 101 103)" --header-border sharp],919+ %[--header "$(seq 101 103)" --header-border sharp --header-first],920+ %[--header "$(seq 101 103)" --header-border sharp --header-lines 3],921+ %[--header "$(seq 101 103)" --header-border sharp --header-lines 3 --header-lines-border sharp],922+ %[--header "$(seq 101 103)" --header-border sharp --header-lines 3 --header-lines-border sharp --header-first],923+ %[--header "$(seq 101 103)" --header-border sharp --header-lines 3 --header-lines-border sharp --header-first --input-border sharp],924+ %[--header "$(seq 101 103)" --header-border sharp --header-lines 3 --header-lines-border sharp --header-first --no-input],925+ %[--header "$(seq 101 103)" --input-border sharp],926+ %[--header "$(seq 101 103)" --style full:sharp],927+ %[--header "$(seq 101 103)" --style full:sharp --header-first],928+ ]929+ output = <<~BLOCK930+ ┌──────── ┌──────── ┌──────── ┌──────── ┌──────── ┌──────── ┌──────── ┌──────── ┌──────── ┌──────── ┌───────── ┌─────── ┌───────── ┌───────── ┌─────────931+ │ > 1 │ > 1 │ > 1 │ 1 │ 1 │ > 1 │ > 1 │ 1 │ ┌────── │ ┌────── │ ┌─────── │ ┌───── │ > 1 │ ┌─────── │ ┌───────932+ │ 2 │ 2 │ 2 │ 2 │ 2 │ 2 │ 2 │ 2 │ │ 1 │ │ 1 │ │ 1 │ │ 1 │ 2 │ │ > 1 │ │ > 1933+ │ 3 │ 3 │ 3 │ 3 │ 3 │ 3 │ 3 │ 3 │ │ 2 │ │ 2 │ │ 2 │ │ 2 │ 3 │ │ 2 │ │ 2934+ │ 4 │ 4 │ 4 │ > 4 │ > 4 │ 4 │ 4 │ > 4 │ │ 3 │ │ 3 │ │ 3 │ │ 3 │ 4 │ │ 3 │ │ 3935+ │ 5 │ 5 │ 5 │ 5 │ 5 │ 5 │ 5 │ 5 │ └────── │ └────── │ └─────── │ └───── │ 5 │ │ 4 │ │ 4936+ │ 5/5 ─ │ 101 │ 5/5 ─ │ 101 │ 2/2 ─ │ ┌────── │ 5/5 ─ │ ┌────── │ > 4 │ > 4 │ > 4 │ > 4 │ 101 │ │ 5 │ │ 5937+ │ > │ 102 │ > │ 102 │ > │ │ 101 │ > │ │ 101 │ 5 │ 5 │ 5 │ 5 │ 102 │ └─────── │ └───────938+ └──────── │ 103 │ 101 │ 103 │ 101 │ │ 102 │ ┌────── │ │ 102 │ ┌────── │ 2/2 ─ │ ┌─────── │ ┌───── │ 103 │ ┌─────── │ ┌───────939+ │ 5/5 ─ │ 102 │ 2/2 ─ │ 102 │ │ 103 │ │ 101 │ │ 103 │ │ 101 │ > │ │ 2/2 │ │ 101 │ ┌─────── │ │ 101 │ │ >940+ │ > │ 103 │ > │ 103 │ └────── │ │ 102 │ └────── │ │ 102 │ ┌────── │ │ > │ │ 102 │ │ 5/5 │ │ 102 │ └───────941+ └──────── └──────── └──────── └──────── │ 5/5 ─ │ │ 103 │ 2/2 ─ │ │ 103 │ │ 101 │ └─────── │ │ 103 │ │ > │ │ 103 │ ┌───────942+ │ > │ └────── │ > │ └────── │ │ 102 │ ┌─────── │ └───── │ └─────── │ └─────── │ │ 101943+ └──────── └──────── └──────── │ 2/2 ─ │ │ 103 │ │ 101 └─────── └───────── │ ┌─────── │ │ 102944+ │ > │ └────── │ │ 102 │ │ > │ │ 103945+ └──────── └──────── │ │ 103 │ └─────── │ └───────946+ │ └─────── └───────── └─────────947+ └─────────948+ BLOCK949+950+ expects = []951+ output.each_line.first.scan(/\S+/) do952+ offset = Regexp.last_match.offset(0)953+ expects << output.lines.filter_map { it[offset[0]...offset[1]]&.strip }.take_while { !it.empty? }.join("\n")954+ end955+956+ suffixes.zip(expects).each do |suffix, block|957+ tmux.send_keys(prefix + suffix, :Enter)958+ tmux.until { assert_block(block, it) }959+960+ teardown961+ setup962+ end963+ end964 endmodified:CHANGELOG.md+1 added
68 unmodified lines69 # You will see 3 items in the list section70 fzf --style full --height 1% --min-height 3+71 ```72 - Shell integration scripts were updated to use `--min-height 20+` by default73+- `--header-lines` will be displayed at the top in `reverse-list` layout74 - Added `bell` action to ring the terminal bell75 ```sh76 # Press CTRL-Y to copy the current line to the clipboard and ring the bell77 fzf --bind 'ctrl-y:execute-silent(echo -n {} | pbcopy)+bell'2436 unmodified lines