fix(reader): Keep diagrams after quick resizes, and add width keys

Merged
DE
5d ago
+202-15

Refs #46.

Diagrams vanishing on resize

After several resizes in a row (dragging a pane edge), Rex drops the uploaded kitty images. Leaf kept placing the old ids, which showed nothing and left an empty gap. A resize now frees and re-uploads every figure (App::resized).

Checked in Rex 0.1.0-preview.20 by toggling pane zoom 7–12 times on a short Mermaid diagram: the old build lost the diagram 2/2 times, this build kept it 2/2.

Reading width keys

  • < / > narrow or widen the column by 8 columns (minimum 20).
  • = fits the column to the screen, and again returns to reader.max_width.

Changes last for the session. The pen and eraser now share a row in the ? list so quit still fits on a 30-row screen.

Screenshots (Rex)

Pane zoom toggled 12 times on a short Mermaid diagram.

Before: diagram goneAfter: diagram kept
beforeafter

= fits the column to the pane, so the sequence diagram from #46 is readable:

fit width

Tests

  • a_resize_uploads_figures_again_because_terminals_may_drop_them
  • angle_brackets_narrow_and_widen_the_column_and_equals_fits_the_screen
  • cargo test: all pass. cargo clippy: same 5 existing warnings.

šŸ¤– Generated with Claude Code


Summary by cubic

Fixes diagrams and ink vanishing after several quick resizes by re-uploading them on every resize, and adds </> to narrow or widen the reading column plus = to fit it to the screen (pressing = again returns to the configured max_width). Width keys pressed before the next frame each count toward the new width, and the pen and eraser now share a row in the key list so quit still fits on short screens.