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

consider wide chars on calculating tab width

Этот коммит содержится в:
rhysd
2023-10-21 00:30:36 +09:00
родитель b5a9f405e8
Коммит 68275e4932
5 изменённых файлов: 57 добавлений и 16 удалений

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

@@ -1,2 +1,3 @@
mod cursor;
mod history;
mod textarea;

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);
}
}