Skip to content

Commit b478df9

Browse files
committed
Fix help lines rendering
1 parent ff9245b commit b478df9

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

internal/ui/app.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,7 @@ func (m model) helpView() string {
335335
contentHeight := m.h - 5
336336
keyLines := []string{}
337337
descLines := []string{}
338-
for i, h := range helpItems() {
339-
if i < m.helpOffset {
340-
continue
341-
}
342-
if len(keyLines) >= contentHeight {
343-
break
344-
}
338+
for _, h := range helpItems() {
345339
keys := make([]string, 0, len(h.keys))
346340
for _, k := range h.keys {
347341
keys = append(keys, "<"+helpKeyStyle.Render(k)+">")
@@ -350,12 +344,23 @@ func (m model) helpView() string {
350344
keyLines = append(keyLines, keyLine)
351345
descLines = append(descLines, h.desc)
352346
}
353-
lines := lipgloss.JoinHorizontal(lipgloss.Top,
347+
linesJoined := lipgloss.JoinHorizontal(lipgloss.Top,
354348
lipgloss.JoinVertical(lipgloss.Right, keyLines...),
355349
lipgloss.JoinVertical(lipgloss.Left, descLines...),
356350
)
357-
padLines := strings.Repeat("\n", contentHeight-lipgloss.Height(lines))
358-
content := helpContentStyle.Render(lines + padLines)
351+
lines := []string{}
352+
for i, line := range strings.Split(linesJoined, "\n") {
353+
if i < m.helpOffset {
354+
continue
355+
}
356+
if len(lines) >= contentHeight {
357+
break
358+
}
359+
lines = append(lines, line)
360+
}
361+
362+
padLines := strings.Repeat("\n", contentHeight-len(lines))
363+
content := helpContentStyle.Render(strings.Join(lines, "\n") + padLines)
359364

360365
footerView := footerDividerStyle.Render(" | ") + footerMsgStyle.Render("Help ")
361366

0 commit comments

Comments
 (0)