Skip to content

Comments

Desktop: Fixes #13745: Prevent cut events from being merged with other actions in the undo history#13791

Merged
laurent22 merged 7 commits intolaurent22:devfrom
personalizedrefrigerator:pr/desktop/fix-clipboard
Nov 29, 2025
Merged

Desktop: Fixes #13745: Prevent cut events from being merged with other actions in the undo history#13791
laurent22 merged 7 commits intolaurent22:devfrom
personalizedrefrigerator:pr/desktop/fix-clipboard

Conversation

@personalizedrefrigerator
Copy link
Collaborator

@personalizedrefrigerator personalizedrefrigerator commented Nov 25, 2025

Summary

This pull request updates the textCut command to prevent "cut" actions from being merged with other actions in the undo history.
Fixes #13745.

Notes

  • An alternative might be to use CodeMirror's native copy/paste functionality with dispatchEvent(new ClipboardEvent(...)). There isn't a documented way to run CodeMirror's cut/copy/paste handlers, so this approach may be fragile. Furthermore, it seems to fail on Windows (see comment).

Testing

This pull request includes a Playwright test for full-line cut/copy/paste. It has additionally been manually verified that:

  • Typing text, then quickly cutting text on a different line, doesn't result in the cut and typing actions being merged.
  • It's possible to copy the content of a note and paste it into another empty note.
  • It's possible to paste a screenshot into the editor.

@mrjo118
Copy link
Contributor

mrjo118 commented Nov 26, 2025

FYI the issue fixed in the title is correct, but the hyperlink in the description is wrong. It should be #13745

@personalizedrefrigerator personalizedrefrigerator marked this pull request as draft November 26, 2025 00:40
const event = new ClipboardEvent(action.type, {
clipboardData,
});
view.contentDOM.dispatchEvent(event);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Converting to a draft. Based on the CI failure, this approach doesn't seem to work on Windows.

It may make sense to use this approach (in the original commit) instead.

…pboard handler for copy/cut/paste"

This reverts commit 1076ec8.
@personalizedrefrigerator personalizedrefrigerator changed the title Desktop: Fixes #13745: Use the native CodeMirror clipboard handler for copy/cut/paste Desktop: Fixes #13745: Prevent cut events from being merged with other actions in the undo history Nov 26, 2025
@personalizedrefrigerator personalizedrefrigerator marked this pull request as ready for review November 26, 2025 18:44
@laurent22 laurent22 merged commit 31cb404 into laurent22:dev Nov 29, 2025
11 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.

'Undo' undoes too much and then results in data loss with undo/redo

3 participants