Skip to content
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

Optimize selection restoring algorithm #2690

Closed
scofalik opened this issue May 4, 2016 · 1 comment
Closed

Optimize selection restoring algorithm #2690

scofalik opened this issue May 4, 2016 · 1 comment
Assignees
Labels
package:undo type:improvement This issue reports a possible enhancement of an existing feature.
Milestone

Comments

@scofalik
Copy link
Contributor

scofalik commented May 4, 2016

Right now the selection restoring algorithm is pretty naive. Selection just before the first operation from a batch is remembered. Then, when that batch is undone, the remembered ranges are retrieved and they are transformed by all the operations from the history that happened after that ranges got remembered.

Consider this deltas history stack, done by two batches (ABC and 123 batches):

<selection state 1 saved>
1
2
<selection state A saved>
A
B
3
C

After ABC batch is reversed, the history is as follows:

<selection state 1 saved>
1
2
<selection state A saved>
A
B
3
C
C'
B'
A'

and <selection state A> is transformed by A, B, 3, C, C', B', A' to get to proper state.

It feels redundant that we have to transform selection by deltas from batch ABC and then by it reversed+transformed counterparts if changes done by batch ABC are removed. On the other hand we cannot simply transform selection just by delta 3 because delta 3 "remembers" the A and B deltas.

We can, however, get a version of 3 that is trasformed by reversed A and B. Let's call it 3'. That would be a version of 3 that does not "remember" A and B. Then - we could transform the selection only by 3'.

It's true that transforming 3 to 3' would take some time, but I think that in some cases this might result in much less steps for selection transforming which means it would be faster and easier to debug.

Also, right now, this case needs 6 range transformation steps:

<selection state A saved>
A
B
C
C'
B'
A'

Where it's clear that it requires none.

@scofalik scofalik self-assigned this Jun 22, 2016
@pjasiun
Copy link

pjasiun commented Jun 24, 2016

Closed via ckeditor/ckeditor5-undo#14.

@pjasiun pjasiun closed this as completed Jun 24, 2016
scofalik referenced this issue in ckeditor/ckeditor5-undo Mar 28, 2017
@mlewand mlewand transferred this issue from ckeditor/ckeditor5-undo Oct 9, 2019
@mlewand mlewand added this to the v0.1.0 milestone Oct 9, 2019
@mlewand mlewand added type:improvement This issue reports a possible enhancement of an existing feature. package:undo labels Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:undo type:improvement This issue reports a possible enhancement of an existing feature.
Projects
None yet
Development

No branches or pull requests

3 participants