From 84e70c0e73460e5db1297c47d02d9b76802bfdf7 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 18 Nov 2026 12:28:29 +0100 Subject: 0.9.1: correctness fixes from the audit - 64 MiB limit detected by file length, so pipelines and redirects are reported - bash temp files removed on every path via a scope guard - validate requires content/new as the schemas declare (present, may be empty) - Session::open folds in model-switch records; resume matches --list - combining mark at a wrap boundary no longer counts as a new row - --flag=value accepted; flag-shaped values rejected - dead code removed; last_reply folded into open (one read per resume) --- src/line.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/line.rs') diff --git a/src/line.rs b/src/line.rs index 2b6c894..9877c48 100644 --- a/src/line.rs +++ b/src/line.rs @@ -65,7 +65,6 @@ impl Editor { let width = terminal_width(); let (cursor_row, _) = layout(prompt, &buffer, cursor, width); state.cursor_row = cursor_row; - state.rows = layout(prompt, &buffer, buffer.len(), width).0 + 1; } Event::Key(key) if key.kind == KeyEventKind::Press => { match handle_key(key, &mut buffer, &mut cursor, self) { @@ -271,17 +270,16 @@ fn layout(prompt: &str, buffer: &[char], upto: usize, width: usize) -> (usize, u pending_wrap = false; continue; } + let cells = cells(ch, col); + if cells == 0 { + // Combining marks draw on top of the previous cell and never wrap. + continue; + } if pending_wrap { row += 1; col = 0; pending_wrap = false; } - - let cells = cells(ch, col); - if cells == 0 { - // Combining marks draw on top of the previous cell. - continue; - } if col + cells > width { row += 1; col = 0; @@ -310,7 +308,6 @@ fn cells(ch: char, col: usize) -> usize { /// that row, not by the number of rows the block occupies. #[derive(Default, Clone, Copy)] struct DrawState { - rows: usize, cursor_row: usize, } @@ -358,7 +355,6 @@ fn draw_to( } execute!(out, MoveToColumn(clamp(cursor_col)))?; - state.rows = end_row + 1; state.cursor_row = cursor_row; Ok(()) } @@ -502,6 +498,15 @@ mod tests { ); } + #[test] + fn a_combining_mark_at_the_wrap_boundary_does_not_wrap() { + let text: Vec = ['a', 'b', '\u{0301}'].to_vec(); + // width 2: 'b' fills the last column (pending wrap), the mark must not + // consume that pending wrap and move to a new row. + let (row, col) = layout("", &text, 3, 2); + assert_eq!((row, col), (0, 1)); + } + #[test] fn layout_counts_wide_and_combining_characters() { let wide: Vec = "日本語".chars().collect(); -- cgit v1.2.3