mirror of
https://github.com/openai/codex.git
synced 2026-10-27 08:01:52 +00:00
Fix TUI layout for halfwidth Japanese sound marks (#35962)
## What changed - Use Ratatui-compatible terminal widths throughout TUI layout, preserving full-width counters for long lines. - Wrap and truncate on grapheme boundaries so halfwidth kana sound marks and emoji sequences stay intact. - Apply the corrected sizing to text input, selection popups, status and history cells, Markdown, hyperlinks, and scrollable cloud diffs. ## Testing - Add focused unit and snapshot coverage for wrapping, truncation, cursor and mask alignment, popup columns, status output, session headers, Markdown tables, process output, and scrollable diffs. GitOrigin-RevId: 294ec0bcff743c6bb16d55ec26308524ce741879
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
use super::ScrollableDiff;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn wraps_halfwidth_sound_marks_using_ratatui_width() {
|
||||
let mut diff = ScrollableDiff::new();
|
||||
diff.set_content(vec![
|
||||
"aガbパc".to_string(),
|
||||
"a ゙b".to_string(),
|
||||
"a ゚b".to_string(),
|
||||
]);
|
||||
diff.set_width(/*width*/ 2);
|
||||
|
||||
insta::assert_snapshot!(
|
||||
diff.wrapped_lines().join("\n"),
|
||||
@r"
|
||||
a
|
||||
ガ
|
||||
b
|
||||
パ
|
||||
c
|
||||
a
|
||||
゙b
|
||||
a
|
||||
゚b
|
||||
"
|
||||
);
|
||||
assert_eq!(diff.wrapped_src_indices(), [0, 0, 0, 0, 0, 1, 1, 2, 2]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn does_not_emit_empty_rows_after_full_width_sound_mark_graphemes() {
|
||||
for grapheme in ["ガ", "パ"] {
|
||||
let mut diff = ScrollableDiff::new();
|
||||
diff.set_content(vec![format!("a {grapheme} tail")]);
|
||||
diff.set_width(/*width*/ 2);
|
||||
|
||||
let expected = ["a", grapheme, "ta", "il"];
|
||||
let actual = diff
|
||||
.wrapped_lines()
|
||||
.iter()
|
||||
.map(String::as_str)
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(actual, expected);
|
||||
assert_eq!(diff.wrapped_src_indices(), [0, 0, 0, 0]);
|
||||
assert_eq!(diff.state.content_h, 4);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user