fix(tui): F-006 flatten multi-line paste in input render

A multi-line paste put raw newlines into the single-line input slot, overflowing
the fixed-height box and leaving a smeared/stale region. flattenForDisplay collapses
newlines (↵) and tabs for rendering only; the inputBuffer keeps real characters for
submission.
This commit is contained in:
2026-06-10 11:13:45 +04:00
parent ee24b7786a
commit 8c9ca9db00
2 changed files with 35 additions and 1 deletions
+9 -1
View File
@@ -206,6 +206,14 @@ func (m Model) renderMain(h int) string {
// --- input bar ---
// flattenForDisplay collapses control characters (newlines from a multi-line paste, tabs)
// to a single visible line so the fixed-height input box can't overflow and smear stale cells
// (F-006). The underlying inputBuffer keeps its real characters for submission.
func flattenForDisplay(s string) string {
repl := strings.NewReplacer("\r\n", "↵ ", "\r", "↵ ", "\n", "↵ ", "\t", " ")
return repl.Replace(s)
}
func (m Model) renderInput() string {
t := m.theme
@@ -231,7 +239,7 @@ func (m Model) renderInput() string {
case m.inputBuffer == "":
line = caret + t.span(placeholder, t.P.Faint)
default:
line = t.span(m.inputBuffer, t.P.FgStrong) + caret
line = t.span(flattenForDisplay(m.inputBuffer), t.P.FgStrong) + caret
}
// status sub-line: <session/none> · <uuid> · <mode>