Skip to content

Commit

Permalink
Remove header indentation when unnecessary
Browse files Browse the repository at this point in the history
  # Indent the header to align with the entries in the list
  fzf --header 'Hello' --header-border --list-border

  # No extra indentation required
  fzf --header 'Hello' --header-border
  • Loading branch information
junegunn committed Jan 6, 2025
1 parent 5ae60e2 commit 328af1f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
6 changes: 5 additions & 1 deletion src/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -2386,7 +2386,11 @@ func (t *Terminal) printHeaderImpl() {
}
// Wrapping is not supported for header
wrap := t.wrap
indent := strings.Repeat(" ", t.pointerLen+t.markerLen)
indentSize := t.pointerLen + t.markerLen
if t.headerBorderShape.HasLeft() && !t.listBorderShape.HasLeft() {
indentSize = util.Max(0, indentSize-(1+t.borderWidth))
}
indent := strings.Repeat(" ", indentSize)
t.wrap = false
for idx, lineStr := range append(append([]string{}, t.header0...), t.header...) {
line := idx
Expand Down
12 changes: 6 additions & 6 deletions test/test_go.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3588,9 +3588,9 @@ def test_header_border_and_label
│ 11
│ > 10
│ ┌────────
│ │ 3
│ │ 2
│ │ 1
│ │ 3
│ │ 2
│ │ 1
│ └header──
│ 19/97 ─
│ > 1
Expand All @@ -3609,9 +3609,9 @@ def test_header_border_and_label_header_first
│ 19/97 ─
│ > 1
│ ┌────────
│ │ 3
│ │ 2
│ │ 1
│ │ 3
│ │ 2
│ │ 1
│ └header──
╰────────────
Expand Down

0 comments on commit 328af1f

Please sign in to comment.