on main help sign in
fix(ui): fix cases where compact header and footer bleed off screen (#2279)
e3376adChristian Rocha
internal/ui/model/header.go+10−8
@@ -17,10 +17,11 @@ import (
17)
17)
18
18
19const (
19const (
20− headerDiag = "╱"
20+ headerDiag = "╱"
21− minHeaderDiags = 3
21+ minHeaderDiags = 3
22− leftPadding = 1
22+ leftPadding = 1
23− rightPadding = 1
23+ rightPadding = 1
24+ diagToDetailsSpacing = 1 // space between diagonal pattern and details section
24)
25)
25
26
26type header struct {
27type header struct {
@@ -73,7 +74,7 @@ func (h *header) drawHeader(
73 var b strings.Builder
74 var b strings.Builder
74 b.WriteString(h.compactLogo)
75 b.WriteString(h.compactLogo)
75
76
76− availDetailWidth := width - leftPadding - rightPadding - lipgloss.Width(b.String()) - minHeaderDiags
77+ availDetailWidth := width - leftPadding - rightPadding - lipgloss.Width(b.String()) - minHeaderDiags - diagToDetailsSpacing
77 details := renderHeaderDetails(
78 details := renderHeaderDetails(
78 h.com,
79 h.com,
79 session,
80 session,
@@ -86,7 +87,8 @@ func (h *header) drawHeader(
86 lipgloss.Width(b.String()) -
87 lipgloss.Width(b.String()) -
87 lipgloss.Width(details) -
88 lipgloss.Width(details) -
88 leftPadding -
89 leftPadding -
89− rightPadding
90+ rightPadding -
91+ diagToDetailsSpacing
90
92
91 if remainingWidth > 0 {
93 if remainingWidth > 0 {
92 b.WriteString(t.Header.Diagonals.Render(
94 b.WriteString(t.Header.Diagonals.Render(
@@ -143,8 +145,8 @@ func renderHeaderDetails(
143 const dirTrimLimit = 4
145 const dirTrimLimit = 4
144 cfg := com.Config()
146 cfg := com.Config()
145 cwd := fsext.DirTrim(fsext.PrettyPath(cfg.WorkingDir()), dirTrimLimit)
147 cwd := fsext.DirTrim(fsext.PrettyPath(cfg.WorkingDir()), dirTrimLimit)
146− cwd = ansi.Truncate(cwd, max(0, availWidth-lipgloss.Width(metadata)), "…")
147 cwd = t.Header.WorkingDir.Render(cwd)
148 cwd = t.Header.WorkingDir.Render(cwd)
148
149
149− return cwd + metadata
150+ result := cwd + metadata
151+ return ansi.Truncate(result, max(0, availWidth), "…")
150}
152}
internal/ui/model/status.go+3−1
@@ -46,7 +46,9 @@ func (s *Status) ClearInfoMsg() {
46
46
47// SetWidth sets the width of the status bar and help view.
47// SetWidth sets the width of the status bar and help view.
48func (s *Status) SetWidth(width int) {
48func (s *Status) SetWidth(width int) {
49+ helpStyle := s.com.Styles.Status.Help
50+ horizontalPadding := helpStyle.GetPaddingLeft() + helpStyle.GetPaddingRight()
49− s.help.SetWidth(width)
51+ s.help.SetWidth(width - horizontalPadding)
50}
52}
51
53
52// ShowingAll returns whether the full help view is shown.
54// ShowingAll returns whether the full help view is shown.
internal/ui/model/ui.go+1−1
@@ -1815,7 +1815,7 @@ func (m *UI) drawHeader(scr uv.Screen, area uv.Rectangle) {
1815 m.session,
1815 m.session,
1816 m.isCompact,
1816 m.isCompact,
1817 m.detailsOpen,
1817 m.detailsOpen,
1818− m.width,
1818+ area.Dx(),
1819 )
1819 )
1820}
1820}
1821
1821