Skip to content

Fix undo not fully reverting image and SVG imports#3906

Open
ziad-ashraf7 wants to merge 2 commits intoGraphiteEditor:masterfrom
ziad-ashraf7:fix-image-import-undo
Open

Fix undo not fully reverting image and SVG imports#3906
ziad-ashraf7 wants to merge 2 commits intoGraphiteEditor:masterfrom
ziad-ashraf7:fix-image-import-undo

Conversation

@ziad-ashraf7
Copy link

Fixes: #3904

Before:

(See the video in the mentioned issue)

After:

2026-03-17.03-13-24.mp4

Files Changed:

editor/src/messages/portfolio/document/document_message_handler.rs

Description:

When importing an image or SVG, the SetDisplayName call was creating a separate history step because
skip_adding_history_step was set to false.

This meant a single undo would only revert the rename, requiring a second undo to actually delete the imported layer.

Setting skip_adding_history_step to true keeps the rename as part of the same transaction as the layer creation, so one undo fully reverts the import.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 where undoing an image or SVG import required two separate undo actions. By consolidating the layer creation and display name assignment into a single history step, the change streamlines the undo process, allowing users to fully revert an import with just one undo command, thereby improving the user experience.

Highlights

  • Undo Behavior Fix: Modified the SetDisplayName call during image and SVG imports to set skip_adding_history_step to true. This change ensures that the layer creation and display name assignment are treated as a single history step, allowing a single undo action to fully revert an import.
Changelog
  • editor/src/messages/portfolio/document/document_message_handler.rs
    • Modified skip_adding_history_step to true for SetDisplayName calls within the image and SVG import logic.
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.

Copy link
Contributor

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

Choose a reason for hiding this comment

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

Code Review

This pull request fixes an issue where undoing an image or SVG import required two undo steps. The change correctly sets skip_adding_history_step to true for the SetDisplayName call during import, ensuring the rename operation is part of the same history transaction as the layer creation. The fix is applied consistently for both image and SVG imports.

Copy link
Contributor

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

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


Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

@Ayush2k02
Copy link
Contributor

yeah LGTM, thanks @0HyperCube for providing details and resolution for this

@ziad-ashraf7
Copy link
Author

Thank you Mr. @Ayush2k02 for approving the PR, so happy for that !

Also Thank you Mr. @0HyperCube for putting me on the right way to solve the issue and have a good exposure on the solution.

Is there anything else that i should do now to make the PR merged ? so I can now look for more issues to resolve.

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.

After importing an image and then doing cmd + z , the layer isn't deleted.

2 participants