Y.UndoManager
fails silently when YTypes from different YDocs are used
#509
Labels
Y.UndoManager
fails silently when YTypes from different YDocs are used
#509
Describe the bug Just spent a while debugging an issue that was caused by a lack of loud warnings when I do the (obvious in retrospect) wrong thing. Namely, the first argument of a
Y.UndoManager
can be either a single Y.Type or an array of Y.Types, but all the Y.Types must be from the same document. This is not mentioned in the docs but is true if you actually dig into the source code, or if you stumble across a utility like this: https://github.com/yjs/y-utility/#ymultidocundomanager. I think that at the very least the Y.UndoManager should throw an error if you try to initialize it with types from different docs.However, due to the existence of
YMultiDocUndoManager
, I think an even better solution would be to have two classes under-the-hood,YMultiDocUndoManager
andYSingleDocUndoManager
, and a unifying classY.UndoManager
, and when someone instantiates aY.UndoManager
you can just check if all theY.Types
are from the same doc. If they are, you useYSingleDocUndoManager
and if they're not you use the multi-doc manager.Or if there is no downside to using
YMultiDocUndoManager
for everything (even when all in the same doc), you just use that code as theY.UndoManager
code.To Reproduce
Huly®: YJS-380
The text was updated successfully, but these errors were encountered: