Skip to content

Drawing ink no longer jumps the view back to the caret (#859) - #892

Merged
echelon merged 2 commits into
storytold:mainfrom
marcoarnulfo:fix/pen-stroke-keeps-view
Oct 12, 2026
Merged

echelon merged 2 commits into
storytold:mainfrom
marcoarnulfo:fix/pen-stroke-keeps-view

Conversation

@marcoarnulfo

Copy link
Copy Markdown
Contributor

Fixes #859.

Every command that isn't view.*, document.* or format.state* sets scroll_to_caret in after_command, and that included the draw.* commands the canvas runs when you lift the pen (draw.stroke), erase (draw.erase) or use the lasso (draw.lasso, draw.lassoMove). On the next frame the canvas scrolled back to the caret, which is usually still on page 1, so every stroke drawn further down the document threw the view away. Drawing never moves the caret (the draw commands only shift its offset when they insert or delete the ink's anchor character), so after_command now leaves draw.* out as well.

Validation:

  • New test drawing_ink_keeps_the_view_where_it_is in crates/ui-egui/src/lib.rs: runs draw.stroke, draw.lasso, draw.lassoMove and draw.erase (each asserted to succeed) and checks none of them asks to scroll to the caret, then checks that text.insert still does. On main it fails with "draw.stroke scrolled to the caret".
  • cargo test -p wordcraft-ui-egui passes, and clippy and fmt are clean (macOS, Apple silicon).

Other commands that act on objects (arrange.*, shape.*, picture.*) take the same path; I left them alone since I haven't checked they never move the caret.

@echelon
echelon merged commit dbfa2af into storytold:main Oct 12, 2026
3 checks passed
@echelon

echelon commented Oct 12, 2026

Copy link
Copy Markdown
Member

Thanks for the contribution, @marcoarnulfo! This is now merged into main. If you haven't already, please come join us on Discord: https://discord.gg/artcraft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drawing with pen

2 participants