fix(ui): calculation bug that would cause modified files to wrap

Christian Rocha created

Change summary

internal/ui/model/session.go | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

Detailed changes

internal/ui/model/session.go 🔗

@@ -213,7 +213,12 @@ func fileList(t *styles.Styles, cwd string, filesWithChanges []SessionFile, widt
 			filePath = rel
 		}
 		filePath = fsext.DirTrim(filePath, 2)
-		filePath = ansi.Truncate(filePath, width-(lipgloss.Width(extraContent)-2), "…")
+		suffix := ""
+		if extraContent != "" {
+			suffix = " " + extraContent
+		}
+		maxPathWidth := max(width-lipgloss.Width(suffix), 0)
+		filePath = ansi.Truncate(filePath, maxPathWidth, "…")
 
 		line := t.Files.Path.Render(filePath)
 		if extraContent != "" {