From 1eebc384f60b73f8c0dbcd2dbcb1ce578702be46 Mon Sep 17 00:00:00 2001 From: salmonik Date: Sun, 15 Nov 2026 17:46:47 +0100 Subject: 0.6.2: resizing no longer duplicates the prompt The terminal reflows the input block and moves the caret with it, so drawing on resize produced a second copy. Recompute the caret's row and let the next redraw work from the reflowed block. Documented the dependency on reflowing terminals. --- src/line.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/line.rs') diff --git a/src/line.rs b/src/line.rs index 613dffe..2b6c894 100644 --- a/src/line.rs +++ b/src/line.rs @@ -58,12 +58,14 @@ impl Editor { draw(prompt, &buffer, cursor, &mut state)?; } Event::Resize(_, _) => { - // The terminal reflowed the block we were tracking, so the - // old row count is meaningless. Start a fresh prompt line - // rather than risk erasing output above it. - println!(); - state = DrawState::default(); - draw(prompt, &buffer, cursor, &mut state)?; + // The terminal has already reflowed the block and moved the + // caret with it, so drawing again here would duplicate the + // prompt. Recompute only where the caret now sits relative + // to the block; the next redraw moves up from there. + 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) { -- cgit v1.2.3