On Sun, Aug 18, 2019 at 8:28 AM Edward K. Ream <edream...@gmail.com> wrote:

>
> On Sun, Aug 18, 2019 at 8:24 AM Edward K. Ream <edream...@gmail.com>
> wrote:
>
> At least one problem is that p changes after:
>
>     child = parent.insertAsNthChild(0)
>

This works:

groupType = 'insert child twice'
undoType = 'insert first child twice'; u = c.undoer
# Start group.
parent = p.parent()
u.beforeChangeGroup(parent, groupType)
# 1
undoData = u.beforeInsertNode(parent)
child = parent.insertAsNthChild(0)
u.afterInsertNode(child, undoType, undoData)
# 2
undoData = u.beforeInsertNode(parent)
child = parent.insertAsNthChild(0)
u.afterInsertNode(child, undoType, undoData)
# End group.
u.afterChangeGroup(parent, groupType)
c.redraw(child)

This fails if p.parent() does not exist, but that's another matter.

Also note the two different undo types.  That's probably not necessary, but
it's better style.

Edward

-- 
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/CAMF8tS1RaaS8qumebOtNLaT%3DLVpx_kajWcTjjQUGfnV8LuW3Ng%40mail.gmail.com.

Reply via email to