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:
@@ -0,0 +1,26 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// F-006: a multi-line paste must collapse to a single display line so the fixed-height
|
||||
// input box can't overflow and leave a smeared/stale region.
|
||||
func TestFlattenForDisplay(t *testing.T) {
|
||||
cases := map[string]string{
|
||||
"plain text": "plain text",
|
||||
"line one\nline two": "line one↵ line two",
|
||||
"crlf\r\nhere": "crlf↵ here",
|
||||
"tab\tseparated": "tab separated",
|
||||
"a\nb\nc": "a↵ b↵ c",
|
||||
}
|
||||
for in, want := range cases {
|
||||
if got := flattenForDisplay(in); got != want {
|
||||
t.Errorf("flattenForDisplay(%q) = %q, want %q", in, got, want)
|
||||
}
|
||||
if strings.ContainsAny(flattenForDisplay(in), "\n\r\t") {
|
||||
t.Errorf("flattenForDisplay(%q) still contains a control char", in)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user