New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix HistoryPlugin selection out of sync #4390
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
See #966 summary recording for a case where undo selection was added. Although it seems to work without undoSelection now, probably addressed with a better calculation of history push vs history merge cases |
@fantactuka - I can repro the same behavior as the test plan without it Mind sharing more details on why we need |
IIRC it was specifically added for cases when few operations coalesced including caret move, and during undo caret position supposed to be in (N-1). That's all I can remember :) I suppose it has been fixed with history merge algo adjustments for selection-change cases, so as long as it works as in test plan above I'm more than happe to remove undoSelection |
That's how it works now which behavior is identical to the previous version. While arguably there's undo nits that don't work like other browsers (line new line) the behavior is the same. Screen.Recording.2023-04-25.at.10.14.03.AM.mov |
Need a proper review on this one...
When the sharedHistory is a shared across parent/nested editors, you can reach a state where the HistoryEntry contains an EditorState and a
undoSelection
that do not point to the editor. This will always cause the editor to crash as it won't be able to find the node to select.For #4389 in particular it seems like this can ocurr when the you previously had a selection on another editor and you then create the first change onto the new editor. The first change will carry the
editor
andeditorEditor
from the previous parent iteration and the selection will bepreviousSelection
of thenestedEditor
, regardless of what the selection of thenestedEditor
is it will never be the selection of the (parent)editor
What I'm suggesting in this PR is to remove any chances that it can be out-of-sync, by relying on the selection in the same EditorState.
But I'm not sure why
undoSelection
was created in the first place so I might be missing something important.Fixes #4389