p argument in undoer beforeXXX and afterXXX

21 views
Skip to first unread message

Brian Theado

unread,
Aug 17, 2019, 11:09:09 PM8/17/19
to leo-editor
I added undo code to the ftlist code I shared in another thread (the code with undo implemented is here: https://gist.github.com/btheado/ca898b8b24b84ba08b3f26f61441cc41). 

The undo operations are working fine, but redo is giving me an assertion error.

It isn't clear to me what Position p are supposed to be passed into the undoer beforeXXX and afterXXX methods. Cloning and moving nodes are the only operations I have. For move, I assume I should be passing the position which is/was moved for both before and after. For clone, should I be passing the original before and the clone after?

My next step if I get a chance tomorrow will be to remove all of the operations but one to see if I can get undo/redo to work for a simpler case and then try to build up from there. I'm open to other ideas.

Here is the assertion error I'm getting on redo:
Traceback (most recent call last):

  File "/home/btheado/src/leo-editor/leo/core/leoGlobals.py", line 296, in new_cmd_wrapper
    func(self, event=event)

  File "/home/btheado/src/leo-editor/leo/core/leoUndo.py", line 1176, in redo
    u.redoHelper()

  File "/home/btheado/src/leo-editor/leo/core/leoUndo.py", line 1284, in redoGroup
    z.redoHelper(); count += 1

  File "/home/btheado/src/leo-editor/leo/core/leoUndo.py", line 1346, in redoMove
    assert u.oldParent_v.children[u.oldN] == v

AssertionError


Brian

Edward K. Ream

unread,
Aug 18, 2019, 9:14:56 AM8/18/19
to leo-editor
On Sat, Aug 17, 2019 at 10:09 PM Brian Theado <brian....@gmail.com> wrote:

It isn't clear to me what Position p are supposed to be passed into the undoer beforeXXX and afterXXX methods.

It's not clear to me either. I owe you, and all of Leo's users, an apology for writing such crappy, undocumented, code ;-)

The undo/redo group operations, which the traceback shows you are using, are particularly tricky.  My guess: there will be problems if the p arg passed to beforeUndoGroup doesn't match the p arg passed to afterUndoGroup. This makes sense: there has to be a stable point somewhere.

Edward
Reply all
Reply to author
Forward
0 new messages