Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This is a WIP!
I'm trying to solve #12002 and #12327, but it touches some things that I'm not so sure about.
The goals is to include selection state in history record so that it can be restored. The basic idea seems to work more or less, but the expectations around restoring selection after undo seem a bit different than what you would think: the very last selection change should be restored, not the selection of the last snapshot.
I try to explain.
[ { value: '' } ]
.[ { value: '', selection: 0 } ]
.{ past: [ { value: '', selection: 0 } ], present: [ { value: 'test', selection: 4 } ] }
{ past: [ { value: '', selection: 0 }, { value: 'test', selection: 4 } ], present: [ { value: 'test', selection: 4 } ] }
[ { value: '', selection: 0 } ]
.This probably means that selection should be continuously passed up to the
editor
module (even if no content changes). There, simple selection change should not create an undo level, of course. But a content change right after a simple selection change should (but not a content change after content change).This would be similar to how it is done in TinyMCE: the bookmark is stored before a change is made:
https://github.com/tinymce/tinymce/blob/1b4c8329a55788e3b5201b1b4df4539cb3397b7d/src/core/main/ts/api/UndoManager.ts#L196-L206
How has this been tested?
Screenshots
Types of changes
Checklist: