1
0
зеркало из https://github.com/glebtv/tui-textarea.git synced 2026-09-08 00:15:50 +03:00

fix TextArea::set_yank_text doesn't support CRLF (\r\n) for newline

Этот коммит содержится в:
rhysd
2023-11-18 16:46:41 +09:00
родитель 306a976fc9
Коммит 1194331a02
2 изменённых файлов: 29 добавлений и 5 удалений

Просмотреть файл

@@ -1420,6 +1420,24 @@ fn test_set_yank_paste_text() {
}
}
#[test]
fn test_set_yank_crlf() {
let tests = [
("\r\n", &["", ""][..], "\n"),
("\r\n\r\n", &["", "", ""][..], "\n\n"),
("a\r\nb", &["a", "b"][..], "a\nb"),
("a\r\nb\r\n", &["a", "b", ""][..], "a\nb\n"),
];
for test in tests {
let (pasted, lines, yanked) = test;
let mut t = TextArea::default();
t.set_yank_text(pasted);
t.paste();
assert_eq!(t.lines(), lines, "{test:?}");
assert_eq!(t.yank_text(), yanked, "{test:?}");
}
}
#[test]
fn test_select_all() {
let mut t = TextArea::from(["aaa", "bbb", "ccc"]);