Skip to content

Commit 621d80d

Browse files
committed
Fix empty inline edit textarea expanding to full height
When the textarea content was empty, trimEndOfBufferLines stripped all lines (including the cursor line) since they all appear as whitespace after ANSI stripping. The fallback returned the full untrimmed view, causing the edit box to fill the entire panel. Fix by stopping the trim loop at 1 instead of 0, so the cursor line is always preserved. Assisted-By: cagent
1 parent a4e7fa1 commit 621d80d

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

pkg/tui/components/messages/messages.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -983,15 +983,13 @@ func trimEndOfBufferLines(view string) string {
983983

984984
// Trim trailing lines that are visually empty (whitespace-only after ANSI strip).
985985
// Content lines always contain visible text or cursor escape sequences.
986+
// Always keep at least one line so that an empty textarea still renders
987+
// the cursor line instead of returning the full padded view.
986988
last := len(lines)
987-
for last > 0 && strings.TrimSpace(ansi.Strip(lines[last-1])) == "" {
989+
for last > 1 && strings.TrimSpace(ansi.Strip(lines[last-1])) == "" {
988990
last--
989991
}
990992

991-
if last == 0 {
992-
return view
993-
}
994-
995993
return strings.Join(lines[:last], "\n")
996994
}
997995

0 commit comments

Comments
 (0)