Skip to content

Commit 2e71df3

Browse files
gitcoder89431claude
andcommitted
fix: footer truncates bindings to fit width instead of wrapping
On narrow terminals the joined binding string would wrap and get clipped by the height constraint, making the footer look blank. Now bindings are added one-by-one until the next one wouldn't fit, so the most important hints (leftmost) are always visible. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 0c5a60c commit 2e71df3

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

internal/components/footer/footer.go

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,31 @@ package footer
33
import (
44
"strings"
55

6+
"charm.land/lipgloss/v2"
67
"github.com/charmbracelet/bubbles/key"
78
"github.com/gitcoder89431/meshd/internal/theme"
89
)
910

1011
func View(bindings []key.Binding, width, height int, t theme.Theme) string {
1112
sep := t.Border.Render(" · ")
12-
parts := make([]string, 0, len(bindings))
13-
for _, binding := range bindings {
14-
help := binding.Help()
15-
parts = append(parts, t.Accent.Render(help.Key)+" "+t.Muted.Render(help.Desc))
13+
sepW := lipgloss.Width(sep)
14+
15+
var parts []string
16+
usedW := 0
17+
for _, b := range bindings {
18+
help := b.Help()
19+
part := t.Accent.Render(help.Key) + " " + t.Muted.Render(help.Desc)
20+
partW := lipgloss.Width(part)
21+
needed := partW
22+
if len(parts) > 0 {
23+
needed += sepW
24+
}
25+
if usedW+needed > width {
26+
break
27+
}
28+
parts = append(parts, part)
29+
usedW += needed
1630
}
31+
1732
return t.Footer.Width(width).Height(height).Render(strings.Join(parts, sep))
1833
}

0 commit comments

Comments
 (0)