fix(tui): preserve CR paste line breaks

This commit is contained in:
Hunter Bown
2026-05-23 21:24:52 -05:00
parent 90a9dfbe7a
commit d1ecb251ea
+16 -3
View File
@@ -395,7 +395,7 @@ fn remove_char_at(text: &mut String, char_index: usize) -> bool {
fn normalize_paste_text(text: &str) -> String {
if text.contains('\r') {
text.replace("\r\n", "\n").replace('\r', "")
text.replace("\r\n", "\n").replace('\r', "\n")
} else {
text.to_string()
}
@@ -5786,11 +5786,24 @@ mod tests {
app.insert_paste_text("a\r\nb\rc");
assert_eq!(app.input, "xa\nbc");
assert_eq!(app.cursor_position, "xa\nbc".chars().count());
assert_eq!(app.input, "xa\nb\nc");
assert_eq!(app.cursor_position, "xa\nb\nc".chars().count());
assert!(!app.paste_burst.is_active());
}
#[test]
fn bracketed_paste_preserves_bare_carriage_return_line_breaks() {
let mut app = App::new(test_options(false), &Config::default());
app.insert_paste_text("alpha\r indented\r# literal heading\r- literal list");
assert_eq!(
app.input,
"alpha\n indented\n# literal heading\n- literal list"
);
assert_eq!(app.cursor_position, app.input.chars().count());
}
#[test]
fn enter_during_active_paste_burst_appends_newline_to_buffer_not_submit() {
// #1073: when chars are still being assembled into a paste burst and