fix(tui): compute truncation budget from actual overhead, not magic numbers
Tags wrapped past pane edge when detail split narrowed the list. Truncation used fixed constants that didn't account for real tag width. Now measures everything-except-body and gives body exactly what remains.
This commit is contained in:
@@ -130,7 +130,8 @@ func renderAbsorbSource(e *db.Entity, maxWidth int) string {
|
|||||||
line := fmt.Sprintf("%s %s%s", glyph, body, tags)
|
line := fmt.Sprintf("%s %s%s", glyph, body, tags)
|
||||||
|
|
||||||
if maxWidth > 0 && len(stripAnsi(line)) > maxWidth {
|
if maxWidth > 0 && len(stripAnsi(line)) > maxWidth {
|
||||||
body = truncate(body, maxWidth-6)
|
overhead := len(stripAnsi(line)) - len([]rune(body))
|
||||||
|
body = truncate(body, maxWidth-overhead)
|
||||||
line = fmt.Sprintf("%s %s%s", glyph, body, tags)
|
line = fmt.Sprintf("%s %s%s", glyph, body, tags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -340,7 +340,8 @@ func renderCard(e *db.Entity, maxWidth int) string {
|
|||||||
line := fmt.Sprintf("%s %s%s%s%s", glyph, body, affordStr, extraStr, useStr)
|
line := fmt.Sprintf("%s %s%s%s%s", glyph, body, affordStr, extraStr, useStr)
|
||||||
|
|
||||||
if maxWidth > 0 && len(stripAnsi(line)) > maxWidth {
|
if maxWidth > 0 && len(stripAnsi(line)) > maxWidth {
|
||||||
body = truncate(body, maxWidth-8)
|
overhead := len(stripAnsi(line)) - len([]rune(body))
|
||||||
|
body = truncate(body, maxWidth-overhead)
|
||||||
line = fmt.Sprintf("%s %s%s%s%s", glyph, body, affordStr, extraStr, useStr)
|
line = fmt.Sprintf("%s %s%s%s%s", glyph, body, affordStr, extraStr, useStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -231,7 +231,8 @@ func renderEntity(e *db.Entity, maxWidth int) string {
|
|||||||
line := fmt.Sprintf("%s %s%s", glyph, body, extraStr)
|
line := fmt.Sprintf("%s %s%s", glyph, body, extraStr)
|
||||||
|
|
||||||
if maxWidth > 0 && len(stripAnsi(line)) > maxWidth {
|
if maxWidth > 0 && len(stripAnsi(line)) > maxWidth {
|
||||||
body = truncate(body, maxWidth-6)
|
overhead := len(stripAnsi(line)) - len([]rune(body))
|
||||||
|
body = truncate(body, maxWidth-overhead)
|
||||||
line = fmt.Sprintf("%s %s%s", glyph, body, extraStr)
|
line = fmt.Sprintf("%s %s%s", glyph, body, extraStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user