This reverts commit 2b7139859e.
This commit is contained in:
@@ -75,7 +75,7 @@ impl TestScenario {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn basic_insertion_no_wrap() {
|
||||
fn hist_001_basic_insertion_no_wrap() {
|
||||
// Screen of 20x6; viewport is the last row (height=1 at y=5)
|
||||
let area = Rect::new(0, 5, 20, 1);
|
||||
let mut scenario = TestScenario::new(20, 6, area);
|
||||
@@ -97,7 +97,7 @@ fn basic_insertion_no_wrap() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn long_token_wraps() {
|
||||
fn hist_002_long_token_wraps() {
|
||||
let area = Rect::new(0, 5, 20, 1);
|
||||
let mut scenario = TestScenario::new(20, 6, area);
|
||||
|
||||
@@ -130,7 +130,7 @@ fn long_token_wraps() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn emoji_and_cjk() {
|
||||
fn hist_003_emoji_and_cjk() {
|
||||
let area = Rect::new(0, 5, 20, 1);
|
||||
let mut scenario = TestScenario::new(20, 6, area);
|
||||
|
||||
@@ -148,7 +148,7 @@ fn emoji_and_cjk() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mixed_ansi_spans() {
|
||||
fn hist_004_mixed_ansi_spans() {
|
||||
let area = Rect::new(0, 5, 20, 1);
|
||||
let mut scenario = TestScenario::new(20, 6, area);
|
||||
|
||||
@@ -162,7 +162,7 @@ fn mixed_ansi_spans() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cursor_restoration() {
|
||||
fn hist_006_cursor_restoration() {
|
||||
let area = Rect::new(0, 5, 20, 1);
|
||||
let mut scenario = TestScenario::new(20, 6, area);
|
||||
|
||||
@@ -182,39 +182,7 @@ fn cursor_restoration() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn word_wrap_no_mid_word_split() {
|
||||
// Screen of 40x10; viewport is the last row
|
||||
let area = Rect::new(0, 9, 40, 1);
|
||||
let mut scenario = TestScenario::new(40, 10, area);
|
||||
|
||||
let sample = "Years passed, and Willowmere thrived in peace and friendship. Mira’s herb garden flourished with both ordinary and enchanted plants, and travelers spoke of the kindness of the woman who tended them.";
|
||||
let buf = scenario.run_insert(vec![Line::from(sample)]);
|
||||
let rows = scenario.screen_rows_from_bytes(&buf);
|
||||
let joined = rows.join("\n");
|
||||
assert!(
|
||||
!joined.contains("bo\nth"),
|
||||
"word 'both' should not be split across lines:\n{joined}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn em_dash_and_space_word_wrap() {
|
||||
// Repro from report: ensure we break before "inside", not mid-word.
|
||||
let area = Rect::new(0, 9, 40, 1);
|
||||
let mut scenario = TestScenario::new(40, 10, area);
|
||||
|
||||
let sample = "Mara found an old key on the shore. Curious, she opened a tarnished box half-buried in sand—and inside lay a single, glowing seed.";
|
||||
let buf = scenario.run_insert(vec![Line::from(sample)]);
|
||||
let rows = scenario.screen_rows_from_bytes(&buf);
|
||||
let joined = rows.join("\n");
|
||||
assert!(
|
||||
!joined.contains("insi\nde"),
|
||||
"word 'inside' should not be split across lines:\n{joined}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pre_scroll_region_down() {
|
||||
fn hist_005_pre_scroll_region_down() {
|
||||
// Viewport not at bottom: y=3 (0-based), height=1
|
||||
let area = Rect::new(0, 3, 20, 1);
|
||||
let mut scenario = TestScenario::new(20, 6, area);
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
#![cfg(feature = "vt100-tests")]
|
||||
|
||||
use ratatui::backend::TestBackend;
|
||||
use ratatui::layout::Rect;
|
||||
use ratatui::text::Line;
|
||||
|
||||
fn term(viewport: Rect) -> codex_tui::custom_terminal::Terminal<TestBackend> {
|
||||
let backend = TestBackend::new(20, 6);
|
||||
let mut term = codex_tui::custom_terminal::Terminal::with_options(backend)
|
||||
.unwrap_or_else(|e| panic!("failed to construct terminal: {e}"));
|
||||
term.set_viewport_area(viewport);
|
||||
term
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stream_commit_trickle_no_duplication() {
|
||||
// Viewport is the last row (height=1 at y=5)
|
||||
let area = Rect::new(0, 5, 20, 1);
|
||||
let mut t = term(area);
|
||||
|
||||
// Step 1: commit first row
|
||||
let mut out1 = Vec::new();
|
||||
codex_tui::insert_history::insert_history_lines_to_writer(
|
||||
&mut t,
|
||||
&mut out1,
|
||||
vec![Line::from("one")],
|
||||
);
|
||||
|
||||
// Step 2: later commit next row
|
||||
let mut out2 = Vec::new();
|
||||
codex_tui::insert_history::insert_history_lines_to_writer(
|
||||
&mut t,
|
||||
&mut out2,
|
||||
vec![Line::from("two")],
|
||||
);
|
||||
|
||||
let combined = [out1, out2].concat();
|
||||
let s = String::from_utf8_lossy(&combined);
|
||||
assert_eq!(
|
||||
s.matches("one").count(),
|
||||
1,
|
||||
"history line duplicated: {s:?}"
|
||||
);
|
||||
assert_eq!(
|
||||
s.matches("two").count(),
|
||||
1,
|
||||
"history line duplicated: {s:?}"
|
||||
);
|
||||
assert!(
|
||||
!s.contains("three"),
|
||||
"live-only content leaked into history: {s:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn live_ring_rows_not_inserted_into_history() {
|
||||
let area = Rect::new(0, 5, 20, 1);
|
||||
let mut t = term(area);
|
||||
|
||||
// Commit two rows to history.
|
||||
let mut buf = Vec::new();
|
||||
codex_tui::insert_history::insert_history_lines_to_writer(
|
||||
&mut t,
|
||||
&mut buf,
|
||||
vec![Line::from("one"), Line::from("two")],
|
||||
);
|
||||
|
||||
// The live ring might display tail+head rows like ["two", "three"],
|
||||
// but only committed rows should be present in the history ANSI stream.
|
||||
let s = String::from_utf8_lossy(&buf);
|
||||
assert!(s.contains("one"));
|
||||
assert!(s.contains("two"));
|
||||
assert!(
|
||||
!s.contains("three"),
|
||||
"uncommitted live-ring content should not be inserted into history: {s:?}"
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user