summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2025-01-06 09:28:07 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2025-01-06 09:57:58 +0900
commit328af1f397297729f2d82b23c13ece76099d295f (patch)
tree17ff332c7b4c784fe975caf645d85f5e044cc90f
parent5ae60e2e806adba1652bec64a62caa473004d7ed (diff)
downloadfzf-328af1f397297729f2d82b23c13ece76099d295f.tar.gz
Remove header indentation when unnecessary
# 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
-rw-r--r--src/terminal.go6
-rwxr-xr-xtest/test_go.rb12
2 files changed, 11 insertions, 7 deletions
diff --git a/src/terminal.go b/src/terminal.go
index 344246de..27c2305f 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -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
diff --git a/test/test_go.rb b/test/test_go.rb
index e46e1600..8f52fd62 100755
--- a/test/test_go.rb
+++ b/test/test_go.rb
@@ -3588,9 +3588,9 @@ class TestGoFZF < TestBase
│ 11
│ > 10
│ ┌────────
- │ │ 3
- │ │ 2
- │ │ 1
+ │ │ 3
+ │ │ 2
+ │ │ 1
│ └header──
│ 19/97 ─
│ > 1
@@ -3609,9 +3609,9 @@ class TestGoFZF < TestBase
│ 19/97 ─
│ > 1
│ ┌────────
- │ │ 3
- │ │ 2
- │ │ 1
+ │ │ 3
+ │ │ 2
+ │ │ 1
│ └header──
╰────────────