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.

Copy link
Member

Choose a reason for hiding this comment

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

Ok, would be fine with me then.

However tests seem to fail quite heavily. Maybe it has some unexpected side effects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some failing tests, such as the ones counting characters seem to be timing-related and caused by this change. Making the tests even more flaky with this workaround doesn't seem ideal. Maybe we should discuss and explore an alternative less invasive workaround for this.

@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!

Signed-off-by: Benjamin Frueh <benjamin.frueh@gmail.com>
@juliusknorr juliusknorr force-pushed the fix/init-undomanager-empty-doc branch from 54f60f9 to cff9c03 Compare November 28, 2025 10:44
@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

Hello there,
Thank you so much for taking the time and effort to create a pull request to our Nextcloud project.

We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process.

Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6

Thank you for contributing to Nextcloud and we hope to hear from you soon!

(If you believe you should not receive this message, you can add yourself to the blocklist.)

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants