Skip to content

Fix the Pen tool preview segment disappearing during repeated undo#3791

Merged
Keavon merged 4 commits into
GraphiteEditor:masterfrom
krVatsal:make-preview-line-follow-the-anchor
Jun 8, 2026
Merged

Fix the Pen tool preview segment disappearing during repeated undo#3791
Keavon merged 4 commits into
GraphiteEditor:masterfrom
krVatsal:make-preview-line-follow-the-anchor

Conversation

@krVatsal

Copy link
Copy Markdown
Contributor

Fixes #3790

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @krVatsal, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a bug in the Pen tool where the preview line would become invisible or incorrectly positioned after performing multiple undo actions. The changes ensure that the tool's internal state correctly reflects the current drawing context after an undo, specifically by retaining the FSM state during anchor placement and explicitly updating the bezier curve preview's origin and handles. This provides a more consistent and predictable user experience when using the Pen tool with undo functionality.

Highlights

  • Pen Tool State Retention: Modified the Pen tool's anchor placement logic to ensure the Finite State Machine (FSM) retains its current state instead of resetting to Ready when place_anchor returns None.
  • Undo Preview Fix: Implemented a fix for the Pen tool's preview line to remain visible and correctly positioned after multiple undo operations by synchronizing preview state variables (next_point, next_handle_start, handle_end) and triggering a PointerMove message.
Changelog
  • editor/src/messages/tool/tool_messages/pen_tool.rs
    • Changed place_anchor's unwrap_or fallback to self to maintain the current FSM state.
    • Added logic within the Undo message handler to decrement point_index and synchronize next_point, next_handle_start, and handle_end based on the new point_index.
    • Introduced a PointerMove message dispatch after an undo to immediately update the preview line's position to follow the cursor.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request improves the Pen tool's preview visibility during undo operations by ensuring the internal state is correctly synchronized. However, the updated undo logic introduces a regression where the tool no longer aborts when undoing the first anchor point. This should be corrected to maintain consistent behavior when canceling a path creation.

Comment thread editor/src/messages/tool/tool_messages/pen_tool.rs

@dhruvjamwal dhruvjamwal left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just reviewed the regression on PR #3791 regarding the Pen tool undo logic. Please update for further changes.

Comment thread editor/src/messages/tool/tool_messages/pen_tool.rs
@Keavon Keavon force-pushed the master branch 6 times, most recently from d6228da to e58c1de Compare March 16, 2026 23:03
@Keavon Keavon force-pushed the master branch 5 times, most recently from 9b97ab7 to 2e842cb Compare March 19, 2026 11:00
@Keavon Keavon force-pushed the master branch 2 times, most recently from f07c79b to 76938eb Compare April 29, 2026 12:16
@Keavon Keavon force-pushed the master branch 2 times, most recently from 4b7a823 to 847b8e9 Compare May 17, 2026 14:37
@timon-schelling timon-schelling force-pushed the master branch 2 times, most recently from 15fcaac to d5f0140 Compare May 17, 2026 15:37
@Keavon Keavon force-pushed the make-preview-line-follow-the-anchor branch from 4779004 to cdcde92 Compare June 8, 2026 17:32
@Keavon Keavon changed the title fix preview line to be visible on multiple undo Fix the Pen tool preview segment disappearing during repeated undo Jun 8, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@Keavon Keavon merged commit cc7d700 into GraphiteEditor:master Jun 8, 2026
10 checks passed
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.

Pen tool preview line disappearing during repeated undo

3 participants