mirror of
https://github.com/junegunn/fzf.git
synced 2026-10-07 20:54:41 +08:00
Fix adaptive height with an inline header or footer border
- 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
This commit is contained in:
3 files changed
+35
-3
No files matched your search
+11
-3
@@ -1547,6 +1547,14 @@ func (t *Terminal) visibleInputLinesInList() int {
|
||||
|
||||
// Extra number of lines needed to display fzf
|
||||
func (t *Terminal) extraLines() int {
|
||||
// borderLines() reports zero for BorderInline, but addInline() still
|
||||
// reserves a divider line for it
|
||||
sectionLines := func(shape tui.BorderShape) int {
|
||||
if shape == tui.BorderInline {
|
||||
return 1
|
||||
}
|
||||
return borderLines(shape)
|
||||
}
|
||||
extra := 0
|
||||
if !t.inputless {
|
||||
extra++
|
||||
@@ -1562,16 +1570,16 @@ func (t *Terminal) extraLines() int {
|
||||
}
|
||||
if t.headerVisible {
|
||||
if t.hasHeaderWindow() {
|
||||
extra += borderLines(t.headerBorderShape)
|
||||
extra += sectionLines(t.headerBorderShape)
|
||||
}
|
||||
extra += len(t.header0)
|
||||
if w, shape := t.determineHeaderLinesShape(); w {
|
||||
extra += borderLines(shape)
|
||||
extra += sectionLines(shape)
|
||||
}
|
||||
extra += t.headerLines
|
||||
}
|
||||
if len(t.footer) > 0 {
|
||||
extra += borderLines(t.footerBorderShape)
|
||||
extra += sectionLines(t.footerBorderShape)
|
||||
extra += len(t.footer)
|
||||
}
|
||||
return extra
|
||||
|
||||
Reference in new issue
Block a user