Skip to content
Myr

Hide default separator when a border separates input from list

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

- Applies when adjacent section (header, header lines, or list) draws border line facing input section # No separator below header border fzf --style full --input-border none --header foo # Separator shown; nothing separates input from list fzf --style full --input-border none --header foo --no-header-border - Evaluated dynamically so change-header/toggle-header update it - Inline header is drawn inside list border and not adjacent to input; decide from section actually next to it - Separator is kept when a preview window can be at 'next' position, right next to the input section

authored by Junegunn Choi · committed by Junegunn Choi · parent e877b6f · Browse files · 5 files+117 added−33 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+117 added−33 removed

  • tests:+19 added−19 removed
  • other:+98 added−14 removed

5 files+117 added−33 removed

modified:man/man1/fzf.1+4 added
821 unmodified lines
822.BI "\-\-separator=" "STR"823The given string will be repeated to form the horizontal separator on the info824line (default: '─' or '\-' depending on \fB\-\-no\-unicode\fR).825826Unless explicitly specified, the separator is not displayed if the input827section is already visually separated from the list section by a border line828(e.g. \fB\-\-input\-border\fR or \fB\-\-header\-border\fR).829830ANSI color codes are supported.831832.TP833.B "\-\-no\-separator"
1582 unmodified lines
modified:src/options.go+3 added
3694 unmodified lines
3695func (opts *Options) noSeparatorLine() bool {3696 if opts.Inputless {3697 return true3698 }3699 // NOTE: This does not know that the default separator can be suppressed at3700 // runtime (see Terminal.separatorLength), so the minimum heights derived3701 // from it can be one line taller than strictly necessary.3702 sep := opts.Separator == nil && !opts.InputBorderShape.Visible() || opts.Separator != nil && len(*opts.Separator) > 03703 return noSeparatorLine(opts.InfoStyle, sep)3704}3705
292 unmodified lines
modified:src/terminal.go+83 added-14 removed
269 unmodified lines
270 previewWrapSignWidth int271 ghost string272 separator labelPrinter273 separatorLen int274 separatorAuto bool275 spinner []string276 promptString string277 prompt func()278 promptLen int
1020 unmodified lines
1299 t.footerBorderShape = tui.BorderBottom1300 }1301 }13021303 // The default separator can be suppressed at runtime depending on the1302 // Disable separator by default if input border is set1303 if opts.Separator == nil && !t.inputBorderShape.Visible() || opts.Separator != nil && len(*opts.Separator) > 0 {1304 bar := "─"1305 if opts.Separator != nil {1306 bar = *opts.Separator1307 } else if !t.unicode {1308 bar = "-"1309 }1304 // window layout (see separatorLength)1305 t.separatorAuto = opts.Separator == nil1306 bar := "─"1307 if opts.Separator != nil {1308 bar = *opts.Separator1309 } else if !t.unicode {1310 bar = "-"1311 }1312 if len(bar) > 0 {1313 t.separator, t.separatorLen = t.ansiLabelPrinter(bar, &tui.ColSeparator, true)1314 }13151316 // Gap line
380 unmodified lines
1697 return output, promptLen1698}16991700func (t *Terminal) noSeparatorLine() bool {1698 return t.inputless || noSeparatorLine(t.infoStyle, t.separatorLen > 0)1701 return t.inputless || noSeparatorLine(t.infoStyle, t.separatorLength() > 0)1702}17031704// Effective length of the horizontal separator. The default separator is1705// suppressed when the input section is already visually separated from the1706// list section by a border line.1707func (t *Terminal) separatorLength() int {1708 if t.separatorAuto && t.separatedByBorder() {1709 return 01710 }1711 return t.separatorLen1712}17131714// The default horizontal separator is redundant if the input section is1715// already visually separated from the list section by a border line1716func (t *Terminal) separatedByBorder() bool {1717 if t.inputBorderShape.Visible() {1718 return true1719 }1720 for po := &t.previewOpts; po != nil; po = po.alternative {1721 if po.position == posNext {1722 // A preview window at 'next' position sits right next to the input1723 // section instead. Keep the separator, as the visibility and the1724 // border of the preview window can change at runtime.1725 return false1726 }1727 }1728 hasHeaderLinesWindow, headerLinesShape := t.determineHeaderLinesShape()1729 hasHeaderWindow := t.hasHeaderWindow()1730 if !hasHeaderWindow && !hasHeaderLinesWindow {1731 // No separate window is created for the input section in this case1732 // (see hasInputWindow in resizeWindows), i.e. the input section is1733 // embedded in the list window and no border separates the two1734 return false1735 }17361737 // The input section has its own window. Determine which section it is1738 // facing, and check if the border of that section draws a line toward it.1739 if hasHeaderWindow && !t.headerFirst && t.headerBorderShape != tui.BorderInline {1740 // Header section; an inline header is not a separate section, it is1741 // drawn inside the list border, so it falls through to the branches1742 // below1743 return t.borderFacingInput(t.headerBorderShape)1744 }1745 // The header lines section is next to the input section, except in1746 // reverse-list layout where it is on the other side of the list section,1747 // or with --header-first and no header section where it is moved past the1748 // input section1749 if hasHeaderLinesWindow && t.layout != layoutReverseList && (hasHeaderWindow || !t.headerFirst) {1750 return t.borderFacingInput(headerLinesShape)1751 }1752 // List section1753 return t.borderFacingInput(t.listBorderShape)1754}17551756// Whether the shape draws a horizontal line facing the info line when the1757// section is placed between the input section and the list section1758func (t *Terminal) borderFacingInput(shape tui.BorderShape) bool {1759 if shape == tui.BorderInline {1760 // Embedded between the horizontal lines of the list border1761 return true1762 }1763 if t.layout == layoutReverse {1764 return shape.HasTop()1765 }1766 return shape.HasBottom()1767}17681769func getScrollbar(perLine int, total int, height int, offset int) (int, int) {1770 if total == 0 || total*perLine <= height {1771 return 0, 01772 }
1624 unmodified lines
3397 return3398 }3399 pos := 03400 line := 03401 separatorLen := t.separatorLength()3402 maxHeight := t.window.Height()3403 move := func(y int, x int, clear bool) bool {3404 if y < 0 || y >= maxHeight {3405 return false
19 unmodified lines
3425 trimmed, _ := t.trimRight([]rune(str), maxWidth)3426 str = string(trimmed)3427 width = maxWidth3428 }3360 move(line, pos, t.separatorLen == 0)3429 move(line, pos, separatorLen == 0)3430 if t.reading {3431 t.window.CPrint(tui.ColSpinner, str)3432 } else {3433 t.window.CPrint(tui.ColPrompt, str)3434 }3435 pos += width3436 }3437 printSeparator := func(fillLength int, pad bool) {3369 if t.separatorLen > 0 {3438 if separatorLen > 0 {3439 t.separator(t.window, fillLength)3440 t.window.Print(" ")3441 } else if pad {3442 t.window.Print(strings.Repeat(" ", fillLength+1))3443 }3444 }34453446 if t.infoStyle == infoHidden {3378 if t.separatorLen > 0 {3447 if separatorLen > 0 {3448 if !move(line+1, 0, false) {3449 return3450 }3451 printSeparator(t.window.Width()-1, false)
54 unmodified lines
3506 shiftLen = util.StringWidth(t.ghost)3507 }3508 switch t.infoStyle {3509 case infoDefault:3441 if !move(line+1, 0, t.separatorLen == 0) {3510 if !move(line+1, 0, separatorLen == 0) {3511 return3512 }3513 printSpinner()3514 t.window.Print(" ") // Margin
75 unmodified lines
3590 outputLen += 23591 }35923593 if t.infoStyle == infoInlineRight {3525 if t.separatorLen > 0 {3594 if separatorLen > 0 {3595 if !move(line+1, 0, false) {3596 return3597 }3598 printSeparator(t.window.Width()-1, false)
5038 unmodified lines
modified:test/test_layout.rb+19 added-19 removed
595 unmodified lines
596 │ │ 3597 │ │ 2598 │ │ 1599 │ └header──600 │ 19/97 ─600 │ 19/97601 │ > 1602 │603 ╰────────────604 BLOCK
22 unmodified lines
627 ╰────────────628 ╭────────────629 │ hello630 ╰────────────631 100/100 ─631 100/100632 >633 BLOCK634 tmux.until { assert_block(block2, it) }635
11 unmodified lines
647 ╭──────────648 │ 2649 │ 1650 ╰──────────651 98/98 ─651 98/98652 >653 BLOCK654 tmux.until { assert_block(block1, it) }655
6 unmodified lines
662 │ 2663 │ 1664 │ hello665 ╰──────────666 98/98 ─666 98/98667 >668 BLOCK669 tmux.until { assert_block(block2, it) }670
7 unmodified lines
678 │ 5679 │ 4680 │ > 3681 ╰──────────682 98/98 ─682 98/98683 >684 ╭──────────685 │ 2686 │ 1
30 unmodified lines
717 ╔══════════718 ║ 2719 ║ 1720 ╚══════════721 98/98 ─721 98/98722 >723 BLOCK724 tmux.until { assert_block(block1, it) }725
7 unmodified lines
733 ╚══════════734 ╭──────────735 │ hello736 ╰──────────737 98/98 ─737 98/98738 >739 BLOCK740 tmux.until { assert_block(block2, it) }741
7 unmodified lines
749 │ 5750 │ 4751 │ > 3752 ╰──────────753 98/98 ─753 98/98754 >755 ╔══════════756 ║ 2757 ║ 1
8 unmodified lines
766 ╔══════════767 ║ 2768 ║ 1769 ╚══════════770 98/98 ─770 98/98771 >772 ╭──────────773 │ hello774 ╰──────────
34 unmodified lines
809 │ │ 3810 │ │ 2811 │ │ 1812 │ └header────813 │ 19/97 ─813 │ 19/97814 │ > 1815 │816 ╰──────────────817 BLOCK
6 unmodified lines
824 │ ║ 12825 │ ║ 11826 │ ║ > 10827 │ ╚list══════828 │ 19/97 ─828 │ 19/97829 │ > 1830 │ ┌──────────831 │ │ 3832 │ │ 2
205 unmodified lines
1038 │ > │ 102 │ > │ 102 │ > │ │ 101 │ > │ │ 101 │ 5 │ 5 │ 5 │ 5 │ 102 │ └─────── │ └───────1039 └──────── │ 103 │ 101 │ 103 │ 101 │ │ 102 │ ┌────── │ │ 102 │ ┌────── │ 2/2 ─ │ ┌─────── │ ┌───── │ 103 │ ┌─────── │ ┌───────1040 │ 5/5 ─ │ 102 │ 2/2 ─ │ 102 │ │ 103 │ │ 101 │ │ 103 │ │ 101 │ > │ │ 2/2 │ │ 101 │ ┌─────── │ │ 101 │ │ >1041 │ > │ 103 │ > │ 103 │ └────── │ │ 102 │ └────── │ │ 102 │ ┌────── │ │ > │ │ 102 │ │ 5/5 │ │ 102 │ └───────1042 └──────── └──────── └──────── └──────── │ 5/5 ─ │ │ 103 │ 2/2 ─ │ │ 103 │ │ 101 │ └─────── │ │ 103 │ │ > │ │ 103 │ ┌───────1042 └──────── └──────── └──────── └──────── │ 5/5 │ │ 103 │ 2/2 │ │ 103 │ │ 101 │ └─────── │ │ 103 │ │ > │ │ 103 │ ┌───────1043 │ > │ └────── │ > │ └────── │ │ 102 │ ┌─────── │ └───── │ └─────── │ └─────── │ │ 1011044 └──────── └──────── └──────── │ 2/2 ─ │ │ 103 │ │ 101 └─────── └───────── │ ┌─────── │ │ 1021044 └──────── └──────── └──────── │ 2/2 │ │ 103 │ │ 101 └─────── └───────── │ ┌─────── │ │ 1021045 │ > │ └────── │ │ 102 │ │ > │ │ 1031046 └──────── └──────── │ │ 103 │ └─────── │ └───────1047 │ └─────── └───────── └─────────1048 └─────────
49 unmodified lines
1098 │ 3/3 ─ │ 101 │ 3/3 ─ │ 101 │ 1/1 ─ │ ┌────── │ 3/3 ─ │ │ 1 │ │ 1 │ ┌────── │ │ 1 │ │ 1 │ │ 1 │ > 1 │ │ 21099 │ > │ 102 │ > │ 102 │ > │ │ 101 │ > │ │ 101 │ │ 101 │ │ 101 │ └────── │ └─────── │ └────── │ 101 │ │ > 11100 └──────── │ 3/3 ─ │ 101 │ 1/1 ─ │ 101 │ │ 102 │ ┌────── │ │ 102 │ │ 102 │ │ 102 │ ┌────── │ ┌─────── │ ┌────── │ 102 │ └───────1101 │ > │ 102 │ > │ 102 │ └─HEAD─ │ │ 101 │ └─HEAD─ │ └─HEAD─ │ └─HEAD─ │ │ 101 │ │ 1/1 │ │ 101 │ ─────── │ ┌───────1102 └──────── └──────── └──────── └──────── │ 3/3 ─ │ │ 102 │ 1/1 ─ │ 1/1 ─ │ 1/1 ─ │ │ 102 │ │ > │ │ 102 │ 3/3 │ │ >1102 └──────── └──────── └──────── └──────── │ 3/3 │ │ 102 │ 1/1 │ 1/1 │ 1/1 │ │ 102 │ │ > │ │ 102 │ 3/3 │ │ >1103 │ > │ └─HEAD─ │ > │ > │ > │ └─HEAD─ │ └─────── │ └─HEAD─ │ > │ └───────1104 └──────── └──────── └──────── └──────── └──────── │ 1/1 ─ │ ┌─────── └──────── └──────── │ ┌───────1104 └──────── └──────── └──────── └──────── └──────── │ 1/1 │ ┌─────── └──────── └──────── │ ┌───────1105 │ > │ │ 101 │ │ 1011106 └──────── │ │ 102 │ │ 1021107 │ └─HEAD── │ └─HEAD──1108 └───────── └─────────
49 unmodified lines
1158 │ 3/3 ─ │ 101 │ 3/3 ─ │ 101 │ 1/1 ─ │ ┌────── │ 3/3 ─ │ ┌────── │ └────── │ └─────── │ └────── │ 3 │ │ 21159 │ > │ 102 │ > │ 102 │ > │ │ 101 │ > │ │ 101 │ > 3 │ > 3 │ > 3 │ 101 │ │ 31160 └──────── │ 3/3 ─ │ 101 │ 1/1 ─ │ 101 │ │ 102 │ ┌────── │ │ 102 │ ┌────── │ ┌─────── │ ┌────── │ 102 │ └───────1161 │ > │ 102 │ > │ 102 │ └─HEAD─ │ │ 101 │ └─HEAD─ │ │ 101 │ │ 1/1 │ │ 101 │ ─────── │ ┌───────1162 └──────── └──────── └──────── └──────── │ 3/3 ─ │ │ 102 │ 1/1 ─ │ │ 102 │ │ > │ │ 102 │ 3/3 │ │ >1162 └──────── └──────── └──────── └──────── │ 3/3 │ │ 102 │ 1/1 │ │ 102 │ │ > │ │ 102 │ 3/3 │ │ >1163 │ > │ └─HEAD─ │ > │ └─HEAD─ │ └─────── │ └─HEAD─ │ > │ └───────1164 └──────── └──────── └──────── │ 1/1 ─ │ ┌─────── └──────── └──────── │ ┌───────1164 └──────── └──────── └──────── │ 1/1 │ ┌─────── └──────── └──────── │ ┌───────1165 │ > │ │ 101 │ │ 1011166 └──────── │ │ 102 │ │ 1021167 │ └─HEAD── │ └─HEAD──1168 └───────── └─────────
21 unmodified lines
1190 block = <<~BLOCK1191 │ ┌─label──1192 │ │ header1193 │ └────────1194 │ 10/10 ─1194 │ 10/101195 │ >1196 └──────────1197 BLOCK1198 tmux.until { assert_block(block, it) }
34 unmodified lines
1233 block = <<~BLOCK1234 ┌──────1235 │ 11236 └──────1237 9/9 ─1237 9/91238 >1239 BLOCK1240 tmux.until { assert_block(block, it) }1241 end
508 unmodified lines
modified:CHANGELOG.md+8 added
1 unmodified line
2=========340.74.15------6- The default separator on the info line is no longer shown when the input section is already visually separated from the list section by a border line7 ```sh8 # No separator shown below the header border9 fzf --style full --input-border none --header foo1011 # Separator shown; no border separates the input section from the list section12 fzf --style full --input-border none --header foo --no-header-border13 ```14- Rendering improvements15 - Each frame is now wrapped in synchronized update mode (mode 2026) to reduce flickering on supported terminals16 - Reduced rendering output by 10-23% by skipping redundant SGR sequences17 - Fixed ghost characters and misplaced colors inside Zellij by using CHA instead of CR + CUF for horizontal cursor movement (#4858, zellij-org/zellij#5370)
3373 unmodified lines