зеркало из
https://github.com/glebtv/tui-textarea.git
synced 2026-09-05 15:15:50 +03:00
consider wide chars on calculating tab width
Этот коммит содержится в:
@@ -1,2 +1,3 @@
|
||||
mod cursor;
|
||||
mod history;
|
||||
mod textarea;
|
||||
|
||||
26
tests/textarea.rs
Обычный файл
26
tests/textarea.rs
Обычный файл
@@ -0,0 +1,26 @@
|
||||
use tui_textarea::{CursorMove, TextArea};
|
||||
|
||||
#[test]
|
||||
fn test_insert_soft_tab() {
|
||||
for test in [
|
||||
("", 0, " "),
|
||||
("a", 1, "a "),
|
||||
("abcd", 4, "abcd "),
|
||||
("a", 0, " a"),
|
||||
("ab", 1, "a b"),
|
||||
("abcdefgh", 4, "abcd efgh"),
|
||||
("あ", 1, "あ "),
|
||||
("🐶", 1, "🐶 "),
|
||||
("あ", 0, " あ"),
|
||||
("あい", 1, "あ い"),
|
||||
] {
|
||||
let (input, col, expected) = test;
|
||||
let mut t = TextArea::from([input.to_string()]);
|
||||
t.move_cursor(CursorMove::Jump(0, col));
|
||||
assert!(t.insert_tab(), "{:?}", test);
|
||||
let lines = t.into_lines();
|
||||
assert_eq!(lines.len(), 1, "{:?}, {:?}", lines, test);
|
||||
let line = &lines[0];
|
||||
assert_eq!(line, expected, "{:?}", test);
|
||||
}
|
||||
}
|
||||
Ссылка в новой задаче
Block a user