Re: Invalid position error on redo position move

2019-08-21 Thread Brian Theado
Vitalije, On Wed, Aug 21, 2019 at 5:41 PM vitalije wrote: > Well I didn't tried too hard to make it more readable. It can be improved. > Ok, after looking at it some more, I see that the vnode tree structure involves only a list of children and a list of parents (one parent for each clone).

Re: Invalid position error on redo position move

2019-08-21 Thread vitalije
> I'm finding the vnode code harder to read, but if it works better then it > is better :-). However, is it better because you are the one who wrote it > instead of me :-), or because it is easier to avoid mistakes using vnodes? > Well I didn't tried too hard to make it more readable. It

Re: Invalid position error on redo position move

2019-08-21 Thread Brian Theado
Thanks vitalije for noticing the position error. I wonder why it only gave an error on redo and not also for the original operation. Thanks for the vnode-based code. Based on a quick test, it seems better than my position based code as I haven't seen any errors on undo/redo. I'm finding the

Re: Invalid position error on redo position move

2019-08-21 Thread vitalije
Well after `one_clone = one.clone()`, position `three` becomes invalid, because `one.clone()` inserts cloned node above the node `three`. If you add: three._childIndex += 1 after `one_clone = one.clone()`, there will be no error after executing script. If I were you I would make all tree

Re: Invalid position error on redo position move

2019-08-21 Thread Brian Theado
Thanks, vitalije. The else part of the 'if 1:' was my failed attempt to further simplify the failing case. The error is happening when the code does: insert, clone, move the clone to the first child of node="two" (which already has one child named "three"), undo, redo. I though I might also

Re: Invalid position error on redo position move

2019-08-21 Thread vitalije
In the first case after `if 1:` you have called two times child.copy().moveToNext().moveToNext(), while in the else case you have called it only once. I have tried with one call in both cases and it works without error. Vitalije -- You received this message because you are subscribed to the

Invalid position error on redo position move

2019-08-21 Thread Brian Theado
In the code I've been writing, there is one particular case which gives an "invalid position" error when I redo it. I've written some simplified code which replicates the scenario (even removing the grouped undo allows the issue to duplicate). The code performs 3 individually undoable operations: