Skip to content

Commit f2fbad5

Browse files
committed
fix(pr-sidebar): allow long file names
1 parent eb2624d commit f2fbad5

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

imposters/pr.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@
272272
{
273273
"additions": 27,
274274
"deletions": 2,
275-
"path": "/some/file/with/a/long/path/that/extends/to/the/next/line.tsx",
275+
"path": "/some/file/with/a/long/path/that/is/really/long/and/extends/to/the/next/line.tsx",
276276
"changeType": "MODIFIED"
277277
}
278278
]

ui/components/prsidebar/checks.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,14 +394,15 @@ func (sidebar *Model) renderChecks() string {
394394
)
395395
}
396396

397-
renderedChecks := lipgloss.JoinVertical(lipgloss.Left, failures...)
398-
renderedChecks = lipgloss.JoinVertical(lipgloss.Left, renderedChecks, lipgloss.JoinVertical(lipgloss.Left, waiting...))
399-
renderedChecks = lipgloss.JoinVertical(lipgloss.Left, renderedChecks, lipgloss.JoinVertical(lipgloss.Left, rest...))
397+
parts := make([]string, 0)
398+
parts = append(parts, failures...)
399+
parts = append(parts, waiting...)
400+
parts = append(parts, rest...)
400401

401402
return lipgloss.JoinVertical(
402403
lipgloss.Left,
403404
title,
404-
lipgloss.NewStyle().PaddingLeft(2).Width(sidebar.getIndentedContentWidth()).Render(renderedChecks),
405+
lipgloss.NewStyle().PaddingLeft(2).Width(sidebar.getIndentedContentWidth()).Render(lipgloss.JoinVertical(lipgloss.Left, parts...)),
405406
)
406407
}
407408

ui/components/prsidebar/files.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,24 @@ func (m *Model) renderFile(file data.ChangedFile) string {
6060
icon := m.renderChangeTypeIcon(file.ChangeType)
6161
additions := lipgloss.NewStyle().Foreground(m.ctx.Theme.SuccessText).Width(5).Render(fmt.Sprintf("+%d", file.Additions))
6262
deletions := lipgloss.NewStyle().Foreground(m.ctx.Theme.ErrorText).Width(5).Render(fmt.Sprintf("-%d", file.Deletions))
63-
return lipgloss.NewStyle().MaxWidth(m.width).Render(lipgloss.JoinHorizontal(
64-
lipgloss.Center,
65-
lipgloss.JoinHorizontal(lipgloss.Center, additions, deletions),
63+
prefix := lipgloss.JoinHorizontal(
64+
lipgloss.Top,
65+
lipgloss.JoinHorizontal(lipgloss.Top, additions, deletions),
6666
" ",
6767
icon,
68-
" ",
69-
file.Path,
70-
))
68+
" ")
69+
70+
path := file.Path
71+
remaining := m.getIndentedContentWidth() - lipgloss.Width(prefix)
72+
if len(path) > remaining {
73+
path = lipgloss.JoinVertical(lipgloss.Left, path[0:remaining], " "+path[remaining:])
74+
}
75+
76+
return lipgloss.JoinHorizontal(
77+
lipgloss.Top,
78+
prefix,
79+
path,
80+
)
7181
}
7282

7383
func (m *Model) renderChangeTypeIcon(changeType string) string {

0 commit comments

Comments
 (0)