Final(?) chat view footer fix

This commit is contained in:
Matt Low 2024-10-21 15:50:07 +00:00
parent c9a7eee090
commit 2ea8a73eb5

View File

@ -341,19 +341,20 @@ func (m *Model) layoutFooter(
return footerStyle.Render(left + padding + right)
}
// Insert between left and right segments when they're being truncated
truncSeparator := "..."
// Inserted between left and right segments when they're being truncated
div := "..."
totalAvailableWidth := width - frameWidth - len(truncSeparator)
totalAvailableWidth := width - frameWidth
availableTruncWidth := totalAvailableWidth - len(div)
minVisibleLength := 3
if totalAvailableWidth < 2*minVisibleLength {
minVisibleLength = totalAvailableWidth / 2
if availableTruncWidth < 2*minVisibleLength {
minVisibleLength = availableTruncWidth / 2
}
leftProportion := float64(leftWidth) / float64(leftWidth+rightWidth)
newLeftWidth := int(max(float64(minVisibleLength), leftProportion*float64(totalAvailableWidth)))
newLeftWidth := int(max(float64(minVisibleLength), leftProportion*float64(availableTruncWidth)))
newRightWidth := totalAvailableWidth - newLeftWidth
truncatedLeft := faintStyle.Render(tuiutil.TruncateRightToCellWidth(left, newLeftWidth, ""))