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: insert, clone, then
move. The error comes after undoing the move and then redoing that same
move.

Just sharing in case someone sees something obviously wrong. Otherwise I'll
be digging deeper sometime this week.

Procedure:

   1. Copy the below xml
   2. open a new leo outline
   3. Ctrl-shift-v to paste the nodes
   4. Ctrl-b to execute

Error looks like this:

setCurrentPosition Invalid position: 'newHeadline', root: 'NewHeadline'
select,selectHelper,select_new_node,set_body_text_after_select
setCurrentPosition Invalid position: 'newHeadline', root: 'NewHeadline'
new_cmd_wrapper,redo,redoMove,selectPosition

<?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.20190820213410.1"><vh>redo bug (use ctrl-b)</vh>
<v t="bpt.20190820213730.1"><vh>one</vh></v>
<v t="bpt.20190820213735.1"><vh>two</vh>
<v t="bpt.20190820213740.1"><vh>three</vh></v>
</v>
</v>
</vnodes>
<tnodes>
<t tx="bpt.20190820213410.1">@language python

# Code written to assume this descendent structure
# one
# two
#   three
parent = p; u = c.undoer

# Will the issue still reproduce without the insert?
if 1:
    undoData = u.beforeInsertNode(parent)
    child =parent.insertAsNthChild(0)
    u.afterInsertNode(child, "insert as first child", undoData)
    sibling =  child.copy().moveToNext().moveToNext()
else:
    # Nope. The issue doesn't duplicate with this
    child = parent.copy().moveToFirstChild()
    sibling = child.copy().moveToNext()

undoData = u.beforeCloneNode(child)
clone = child.clone()
u.afterCloneNode(clone, "clone node", undoData)

undoData = u.beforeMoveNode(clone)
clone.moveToFirstChildOf(sibling)
u.afterMoveNode(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.20190820213730.1"></t>
<t tx="bpt.20190820213735.1"></t>
<t tx="bpt.20190820213740.1"></t>
</tnodes>
</leo_file>

-- 
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 leo-editor+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/CAO5X8Cx15dS8oktjUBQ%3DTk8rRTqxTYPR7jhOfcVxa%3DhZnL_4CA%40mail.gmail.com.

Reply via email to