Skip to content

stroke: a pen lifted off the canvas still commits its stroke - #70

Open
foxnne wants to merge 1 commit into
mainfrom
fix/stroke-commit-off-canvas
Open

foxnne wants to merge 1 commit into
mainfrom
fix/stroke-commit-off-canvas

Conversation

@foxnne

@foxnne foxnne commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Part of fizzyedit/work#84 (symptom 1: undo to "Before any change" leaves pixels). Data bug, not display.

File.drawPoint / File.drawLine return early when a point is off the canvas, before the to_change commit. A pen released outside the image (or a shift line ending outside) therefore never became an undo step: the pixels were painted and sit in the stroke buffer / snapshot, then the next press clears both (processStroke press: buffers.stroke.clearAndFree() + strokeUndoBegin). Undo-all can never remove them.

Fix: the off-canvas early return commits the stroke in progress (only when there is one, so a stray click makes no empty step).

Checked and ruled out: the snapshot box covers the brush (brushRect/lineBrushCoverRect match Brush.shapeOf for the tool's stroke_size, expanded before each draw), and the box is never narrower than a fast segment. Overlapping undo/redo is symmetric (applyChange swaps). Independent of #68/#69: neither touches these early returns (the bug is on main and with both applied).

No headless test: File needs the host runtime (runtime.state()), and pixi's zig build test is std-only files. Verified by zig build and by reading; reproduction: draw a stroke, release the pen outside the image, press again elsewhere, undo twice: the first stroke stays.

🤖 Generated with Claude Code

drawPoint/drawLine returned on an off-canvas endpoint before the commit, so a stroke released outside the image (or ended by a shift line with an off-canvas end) never became an undo step; the next press cleared its buffer and the pixels were left behind by undo-all.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@foxnne
foxnne marked this pull request as ready for review October 23, 2026 14:24
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.

1 participant