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 duplicate it by skipping the insert and just cloning the already existing node="one". But still I want to move the clone to the first child of "two". Since the insert was skipped, one fewer moveToNext() was needed in order to get the to new parent node="two". The error given by the code as currently written is what I need to solve. You can ignore the else clause it is just noise :-). Actually, inspired by your response, I found a way to duplicate the error even without the insert. So now it is just clone, move, undo, redo. Here is the new subtree xml: <?xml version="1.0" encoding="utf-8"?> <!-- Created by Leo: http://leoeditor.com/leo_toc.html --> <leo_file xmlns:leo="http://leoeditor.com/namespaces/leo-python-editor/1.1" > <leo_header file_format="2"/> <vnodes> <v t="bpt.20190821091623.1"><vh>redo bug (use ctrl-b)</vh> <v t="bpt.20190821091623.2"><vh>one</vh></v> <v t="bpt.20190821091623.3"><vh>two</vh></v> <v t="bpt.20190821091623.4"><vh>three</vh> <v t="bpt.20190821091623.5"><vh>four</vh></v> </v> </v> </vnodes> <tnodes> <t tx="bpt.20190821091623.1">@language python # Code written to assume this descendent structure # one # two # three # four parent = p; u = c.undoer one = parent.copy().moveToFirstChild() three = one.copy().moveToNext().moveToNext() undoData = u.beforeCloneNode(one) one_clone = one.clone() u.afterCloneNode(one_clone, "clone node", undoData) undoData = u.beforeMoveNode(one_clone) one_clone.moveToFirstChildOf(three) u.afterMoveNode(one_clone, "move node to top", undoData) # Maybe the next step is to set a breakpoint in the "invalid position" # and trace it from there. c.executeMinibufferCommand('undo') c.executeMinibufferCommand('redo')</t> <t tx="bpt.20190821091623.2"></t> <t tx="bpt.20190821091623.3"></t> <t tx="bpt.20190821091623.4"></t> <t tx="bpt.20190821091623.5"></t> </tnodes> </leo_file> On Wed, Aug 21, 2019 at 8:15 AM vitalije <[email protected]> wrote: > 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 Google Groups > "leo-editor" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/leo-editor/fced3afd-898a-493c-8b31-c3e5dbff7adb%40googlegroups.com > <https://groups.google.com/d/msgid/leo-editor/fced3afd-898a-493c-8b31-c3e5dbff7adb%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/CAO5X8Cw40djUZCsRqc5xz0ZfOkqhpG2Fa6z2Q3i7bJVre2JTAw%40mail.gmail.com.
