Skip to content

Conversation

@benjaminfrueh
Copy link
Contributor

The first paste action in an empty document was not being tracked by the Yjs UndoManager, making it impossible to undo and not tracking it as a change.

This adds initUndoManagerForEmptyDocument() which primes the undo manager by inserting and deleting a space, then clearing the undo stack. This ensures user actions are properly tracked.

@benjaminfrueh benjaminfrueh force-pushed the fix/init-undomanager-empty-doc branch from 07762fd to 54f60f9 Compare November 19, 2025 14:43
@benjaminfrueh benjaminfrueh added 3. to review bug Something isn't working labels Nov 19, 2025
},
initUndoManagerForEmptyDocument() {
if (
Copy link
Member

Choose a reason for hiding this comment

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

Is this something that gets added to the history and pushing steps to the server? As discussed I'd be fine with this as a workaround but we should file an upstream issue at least.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@juliusknorr I clear the history after deleting the space, and in my test there were no steps added to the database in this process. I agree that an upstream issue for yjs should be created and this workaround should be removed once the issue is fixed or a better workaround is found.

@codecov
Copy link

codecov bot commented Nov 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants