Skip to content
Myr

Fix adaptive height with an inline header or footer border

Before adoption: this commit came in with the history the project adopted, so no landing records it.

- extraLines() used borderLines(), which reports zero for BorderInline - Divider drawn for an inline section still takes a line, and resizeWindows() reserves it via addInline() - So adaptive height came up one line short per inline section and the list scrolled - Affects --header-lines-border, --header-border and --footer-border alike. All three set came up three lines short - Without a list border the shape normalizes to BorderTop or BorderBottom, which report a line, hence --no-list-border looked like a fix seq 10 | fzf --height=~100% --list-border \ --header-lines=1 --header-lines-border=inline Fix #4904

authored by Junegunn Choi · committed by Junegunn Choi · parent a52ac84 · Browse files · 3 files+35 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+35 added−3 removed

  • tests:+22 added−0 removed
  • other:+13 added−3 removed

3 files+35 added−3 removed

modified:src/terminal.go+11 added-3 removed
1545 unmodified lines
1546}15471548// Extra number of lines needed to display fzf1549func (t *Terminal) extraLines() int {1550 // borderLines() reports zero for BorderInline, but addInline() still1551 // reserves a divider line for it1552 sectionLines := func(shape tui.BorderShape) int {1553 if shape == tui.BorderInline {1554 return 11555 }1556 return borderLines(shape)1557 }1558 extra := 01559 if !t.inputless {1560 extra++1561 if !t.noSeparatorLine() {
7 unmodified lines
1569 extra += borderLines(t.listBorderShape)1570 }1571 if t.headerVisible {1572 if t.hasHeaderWindow() {1565 extra += borderLines(t.headerBorderShape)1573 extra += sectionLines(t.headerBorderShape)1574 }1575 extra += len(t.header0)1576 if w, shape := t.determineHeaderLinesShape(); w {1569 extra += borderLines(shape)1577 extra += sectionLines(shape)1578 }1579 extra += t.headerLines1580 }1581 if len(t.footer) > 0 {1574 extra += borderLines(t.footerBorderShape)1582 extra += sectionLines(t.footerBorderShape)1583 extra += len(t.footer)1584 }1585 return extra1586}
7261 unmodified lines
modified:test/test_layout.rb+22 added
880 unmodified lines
881 BLOCK882 tmux.until { assert_block(block, it) }883 end884885 def test_adaptive_height_with_inline_sections886 tmux.send_keys %(seq 10 | #{FZF} --height=~100% --list-border --header-lines=1 --header-lines-border=inline), :Enter887 block = <<~BLOCK888 ╭──────889 │ 10890 │ 9891 │ 8892 │ 7893 │ 6894 │ 5895 │ 4896 │ 3897 │ > 2898 ├──────899 │ 1900 ╰──────901 9/9902 >903 BLOCK904 tmux.until { assert_block(block, it) }905 end906907 def test_style_full_adaptive_height908 tmux.send_keys %(seq 1| #{FZF} --style=full:rounded --height=~100% --header-lines=1 --info=default), :Enter909 block = <<~BLOCK910 ╭────────
1130 unmodified lines
modified:CHANGELOG.md+2 added
4 unmodified lines
5------6- Fixed an escape sequence split across reads being parsed as a fragment, which leaked the rest into the query (#4899)7 - e.g. A terminal answering the startup `DECRQM` query late left `?2004;2$y`, CTRL-UP left `5A`, and SGR mouse input left `0;1;1M`8- Fixed `--tiebreak=pathname` not detecting the last path separator when the line contains a non-ASCII character before it (#4902)9- Fixed adaptive height not reserving a line for the divider of an inline header or footer border, so the list came up one line short for each of them (#4904)10 - e.g. `seq 10 | fzf --height=~100% --list-border --header-lines=1 --header-lines-border=inline`11- Vim plugin12 - fzf no longer blocks the editor, so live previews keep working while fzf is open13 - `fzf#run` returns an empty list when it runs fzf asynchronously. Use `sink`, `sinklist`, or `exit` to get the result14 - The popup layout now works under Zellij
3432 unmodified lines