Skip to content

Fix image paste and undo handling - #41

Merged
sdottaka merged 2 commits into
masterfrom
fix-image-paste-undo
Oct 18, 2026
Merged

sdottaka merged 2 commits into
masterfrom
fix-image-paste-undo

Conversation

@sdottaka

@sdottaka sdottaka commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Defer canvas resizing until the pasted image is committed.
  • Resize the canvas and paste the image as a single undoable operation.
  • Commit overlapped images before switching pages or copying differences.
  • Update scrollbars when cancelling a paste preview or switching pages.
  • Clip deletion rectangles to the image bounds to prevent out-of-range access.

…hat undo restores the original image size and content.

Copilot AI 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.

🟡 Changes recommended

Cancellation can cause out-of-bounds writes, discard independent edits, and leave stale scrollbar state.

3 open issues
What changed in this PR

Preserves the pre-paste image so undo can restore its original dimensions and content.

Changes:

  • Saves the original image before paste resizing and reuses it for undo.
  • Restores pending paste snapshots on cancellation and clears them on close.
File Description
src/​WinIMergeLib/​ImgMergeWindow.hpp Uses paste-specific resizing and cancellation.
src/​WinIMergeLib/​ImgMergeBuffer.hpp Manages original-image snapshots for paste undo and cancellation.

Review effort: Balanced

Comment thread src/WinIMergeLib/ImgMergeBuffer.hpp Resolved
Comment thread src/WinIMergeLib/ImgMergeWindow.hpp Resolved
Comment thread src/WinIMergeLib/ImgMergeWindow.hpp Resolved
@sdottaka sdottaka changed the title Fix undo behavior when pasting images Fix image paste and undo handling Oct 18, 2026
@sdottaka
sdottaka merged commit ee8a41d into master Oct 18, 2026
1 check passed
@sdottaka
sdottaka deleted the fix-image-paste-undo branch October 18, 2026 09:26
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.

2 participants