Re: Having trouble writing a simple grouped undo/redo

2019-08-25 Thread Edward K. Ream
On Sun, Aug 25, 2019 at 3:36 PM Brian Theado  wrote:

> I submitted pull request
> https://github.com/leo-editor/leo-editor/pull/1302. No new failed test
> cases and the failing test case I added passes.
>

Thanks for the new unit test.  I merged the code and reran all unit tests
in devel.  All seems well.

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/CAMF8tS0t96MhXaXdt_qjfgTFjc-mv04krKZMj-TBEZ6yQ_Nthg%40mail.gmail.com.


Re: Having trouble writing a simple grouped undo/redo

2019-08-25 Thread Edward K. Ream
On Sat, Aug 24, 2019 at 7:56 PM Brian Theado  wrote:

> It turns out the '-m pdb' workaround for the readline crash does work for
> me running unit tests.
>

Two tips.  You can add a call to g.pdb() at the start of any unit test.
Also, I run unitTest.leo with the --fail-fast command-line option.

I decided I wanted to follow the good practice of adding a failing unit
> test which exposes the bug and then show after the fix that same test
> passes. I discovered there are already unit tests for other group undo
> commands like convertAllBlanks and convertAllTabs and I wondered how those
> tests were passing. It turns out all the undo/redo tests start with a fresh
> undo stack. The off-by-one error of this bug causes the bead index to be -1
> instead of 0. But for a single element list array, indices -1 and 0 point
> to the same list element. So the group redo will always function properly
> when it is the only item on the list.
>

Excellent work.

Btw, rev e4d720b appears to fix #460 with a trivial change.

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/CAMF8tS1A0Raz9w4TTMmstTG%2BPeRU7hUnbSyFWhsPUszPZubAqQ%40mail.gmail.com.


Re: Having trouble writing a simple grouped undo/redo

2019-08-24 Thread Brian Theado
It turns out the '-m pdb' workaround for the readline crash does work for
me running unit tests.

I decided I wanted to follow the good practice of adding a failing unit
test which exposes the bug and then show after the fix that same test
passes. I discovered there are already unit tests for other group undo
commands like convertAllBlanks and convertAllTabs and I wondered how those
tests were passing. It turns out all the undo/redo tests start with a fresh
undo stack. The off-by-one error of this bug causes the bead index to be -1
instead of 0. But for a single element list array, indices -1 and 0 point
to the same list element. So the group redo will always function properly
when it is the only item on the list.

In order to duplicate the bug, I will need to write a test containing
multiple commands. I might be out of time for this for a few days, but I
plan to tackle it when I get a chance.

On Wed, Aug 21, 2019 at 7:45 AM Brian Theado  wrote:

> Sure, I'll do that or figure out the segfault issue sometime this week.
>
> On Tue, Aug 20, 2019 at 7:26 AM Edward K. Ream 
> wrote:
>
>> Unfortunately, I'm not able to run unit tests without getting a segfault.
>>>
>> Alright.  Create a new branch, and I'll run the unit tests there.
>>
>

-- 
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/CAO5X8Cxs_P3MHsYWw1eKC9tSNZug9XexBPezsOk0aR%2BqBt7mVQ%40mail.gmail.com.


Re: Having trouble writing a simple grouped undo/redo

2019-08-21 Thread Brian Theado
Sure, I'll do that or figure out the segfault issue sometime this week.

On Tue, Aug 20, 2019 at 7:26 AM Edward K. Ream  wrote:

> Unfortunately, I'm not able to run unit tests without getting a segfault.
>>
> Alright.  Create a new branch, and I'll run the unit tests there.
>

-- 
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/CAO5X8CwnBvyHgojLp4%3DKg1d_YofUAZU5fNTjGn15j-hxEr7rbw%40mail.gmail.com.


Re: Having trouble writing a simple grouped undo/redo

2019-08-20 Thread Edward K. Ream
On Tue, Aug 20, 2019 at 6:22 AM Brian Theado  wrote:

Unfortunately, I'm not able to run unit tests without getting a segfault.
>

Alright.  Create a new branch, and I'll run the unit tests there.

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/CAMF8tS0A8UYisMk8xfV1dZ_xhcK847r2i8WWek7VBj1z_KDkdQ%40mail.gmail.com.


Re: Having trouble writing a simple grouped undo/redo

2019-08-20 Thread Brian Theado
Unfortunately, I'm not able to run unit tests without getting a segfault.
It appears to be related to loading the readline library similar to what I
reported last year:
https://groups.google.com/d/msg/leo-editor/ghiIN7irzY0/2wreFgcYDQAJ. Though
now I'm running Ubuntu 18.04. Something in the unit test code causes pdb to
be loaded which loads readline and causes the crash.

I faced the same issue when trying to set breakpoints in code...invoking
pdb crashed. I solved that by launching leo with 'python -m pdb'. Somehow
when doing it that way there was no crash. However, the same workaround
didn't work for running the unit tests. I have some ideas on tracking it
down further, but I haven't gotten to it yet.

On Tue, Aug 20, 2019 at 6:15 AM Edward K. Ream  wrote:

>
>
> On Mon, Aug 19, 2019 at 7:04 PM Brian Theado 
> wrote:
>
>> I found a core function which uses undo groups and used this code to call
>> it:
>>
>> c.createNodeHierarchy(['a', 'b', 'c'], parent=p)
>> c.redraw(p)
>>
>> Redoing this operation gives the same error as the test code and the
>> bead+1 fixes it also. I think this bug is affecting all grouped redo.
>>
>
> Thanks for this work.  Does the proposed change pass all unit tests?
>
> 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/CAMF8tS20sv7uEzmpFH8Sf65h5JRDF_kX_rvDyggbqK8%2BhJKi5g%40mail.gmail.com
> 
> .
>

-- 
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/CAO5X8Cz%3DQBbjBFEq9EjdRFoCkXq0%3DY6vQTYXPz7GXm7j1xjDaA%40mail.gmail.com.


Re: Having trouble writing a simple grouped undo/redo

2019-08-20 Thread Edward K. Ream
On Mon, Aug 19, 2019 at 7:04 PM Brian Theado  wrote:

> I found a core function which uses undo groups and used this code to call
> it:
>
> c.createNodeHierarchy(['a', 'b', 'c'], parent=p)
> c.redraw(p)
>
> Redoing this operation gives the same error as the test code and the
> bead+1 fixes it also. I think this bug is affecting all grouped redo.
>

Thanks for this work.  Does the proposed change pass all unit tests?

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/CAMF8tS20sv7uEzmpFH8Sf65h5JRDF_kX_rvDyggbqK8%2BhJKi5g%40mail.gmail.com.


Re: Having trouble writing a simple grouped undo/redo

2019-08-19 Thread Brian Theado
I found a core function which uses undo groups and used this code to call
it:

c.createNodeHierarchy(['a', 'b', 'c'], parent=p)
c.redraw(p)

Redoing this operation gives the same error as the test code and the bead+1
fixes it also. I think this bug is affecting all grouped redo.


On Mon, Aug 19, 2019 at 7:54 PM Brian Theado  wrote:

> I think the issue is in u.redoGroup (leo/core/LeoPyRef.leo#Code-->Core
> classes-->@file leoUndo.py-->class Undoer-->u.redo helpers-->u.redoGroup)
>
> The line:
> bunch = u.beads[*u.bead*]; count = 0
>
> Should be:
> bunch = u.beads[*u.bead+1*]; count = 0
>
> That line is in both u.undoGroup and u.redoGroup. For undoGroup u.bead is
> valid, but for redo it should be operating with u.bead+1.
>
> Brian
>
>
> On Sun, Aug 18, 2019 at 5:18 PM Brian Theado 
> wrote:
>
>> Hmm, it didn't work for me. Using your code and following the same steps
>> as my original email, I get the same error message.
>>
>> After that if I start from step #4 (the ctrl-b step) again, then the undo
>> and the redo work. But then if I start again at step #4, I get the original
>> error message again.
>>
>> Could you confirm it is working for you even starting from scratch?
>>
>> On Sun, Aug 18, 2019 at 9:32 AM Edward K. Ream 
>> wrote:
>>
>>>
>>>
>>> On Sun, Aug 18, 2019 at 8:28 AM Edward K. Ream 
>>> wrote:
>>>

 On Sun, Aug 18, 2019 at 8:24 AM Edward K. Ream 
 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
>>> 
>>> .
>>>
>>

-- 
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/CAO5X8CzMuHdJKKhmH1aZ19AGAx3GoVXpNEty_UBcjs5k2A1BPw%40mail.gmail.com.


Re: Having trouble writing a simple grouped undo/redo

2019-08-19 Thread Brian Theado
I think the issue is in u.redoGroup (leo/core/LeoPyRef.leo#Code-->Core
classes-->@file leoUndo.py-->class Undoer-->u.redo helpers-->u.redoGroup)

The line:
bunch = u.beads[*u.bead*]; count = 0

Should be:
bunch = u.beads[*u.bead+1*]; count = 0

That line is in both u.undoGroup and u.redoGroup. For undoGroup u.bead is
valid, but for redo it should be operating with u.bead+1.

Brian


On Sun, Aug 18, 2019 at 5:18 PM Brian Theado  wrote:

> Hmm, it didn't work for me. Using your code and following the same steps
> as my original email, I get the same error message.
>
> After that if I start from step #4 (the ctrl-b step) again, then the undo
> and the redo work. But then if I start again at step #4, I get the original
> error message again.
>
> Could you confirm it is working for you even starting from scratch?
>
> On Sun, Aug 18, 2019 at 9:32 AM Edward K. Ream 
> wrote:
>
>>
>>
>> On Sun, Aug 18, 2019 at 8:28 AM Edward K. Ream 
>> wrote:
>>
>>>
>>> On Sun, Aug 18, 2019 at 8:24 AM Edward K. Ream 
>>> 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
>> 
>> .
>>
>

-- 
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/CAO5X8Cw75Pu9UjwwCwRnrzzC8QhNQ5mgpy-Bg8Jm9x15bvuSFA%40mail.gmail.com.


Re: Having trouble writing a simple grouped undo/redo

2019-08-18 Thread Brian Theado
Hmm, it didn't work for me. Using your code and following the same steps as
my original email, I get the same error message.

After that if I start from step #4 (the ctrl-b step) again, then the undo
and the redo work. But then if I start again at step #4, I get the original
error message again.

Could you confirm it is working for you even starting from scratch?

On Sun, Aug 18, 2019 at 9:32 AM Edward K. Ream  wrote:

>
>
> On Sun, Aug 18, 2019 at 8:28 AM Edward K. Ream 
> wrote:
>
>>
>> On Sun, Aug 18, 2019 at 8:24 AM Edward K. Ream 
>> 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
> 
> .
>

-- 
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/CAO5X8Cwe4q%2B%2BVOoKcWVqPkKBYqF1oHCfEJ1mCnLOTJ-4nn5urg%40mail.gmail.com.


Re: Having trouble writing a simple grouped undo/redo

2019-08-18 Thread Edward K. Ream
On Sun, Aug 18, 2019 at 11:35 AM Brian Theado 
wrote:

> Thanks a lot. I'll give it a try tonight and also see if I can get similar
> code working for clone and move. After that I can try to put it all
> together.
>

You're welcome.  Good luck, and feel free to ask more questions.

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/CAMF8tS3%3D-9ha1c5ociL5R_QrhByrEoyNFqQNms7U%2BA2rCTX8Ew%40mail.gmail.com.


Re: Having trouble writing a simple grouped undo/redo

2019-08-18 Thread Brian Theado
Thanks a lot. I'll give it a try tonight and also see if I can get similar
code working for clone and move. After that I can try to put it all
together.

On Sun, Aug 18, 2019, 9:32 AM Edward K. Ream  wrote:

>
>
> On Sun, Aug 18, 2019 at 8:28 AM Edward K. Ream 
> wrote:
>
>>
>> On Sun, Aug 18, 2019 at 8:24 AM Edward K. Ream 
>> 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
> 
> .
>

-- 
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/CAO5X8Cx_6CbA-k9gNenfD0AiJspE2UAA9vPTEpP-ywK9QS3PUA%40mail.gmail.com.


Re: Having trouble writing a simple grouped undo/redo

2019-08-18 Thread Edward K. Ream
On Sun, Aug 18, 2019 at 8:28 AM Edward K. Ream  wrote:

>
> On Sun, Aug 18, 2019 at 8:24 AM Edward K. Ream 
> 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.


Re: Having trouble writing a simple grouped undo/redo

2019-08-18 Thread Edward K. Ream
On Sun, Aug 18, 2019 at 8:24 AM Edward K. Ream  wrote:

At least one problem is that p changes after:

child = parent.insertAsNthChild(0)

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/CAMF8tS3Y06_YULrBj6LRz2%2Bi6MUZk_Xgq3RjN1%2B2TrYB1H5pmg%40mail.gmail.com.


Re: Having trouble writing a simple grouped undo/redo

2019-08-18 Thread Edward K. Ream
On Sun, Aug 18, 2019 at 8:15 AM Edward K. Ream  wrote:


> I'll take a look asap.
>

I see the behavior you describe.  It persists if I replace p by parent in
the before/after calls.

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/CAMF8tS0EvbqCo9vMRxjiyegJ07BL-hhopNjVTG_UJED%2Bsifnvg%40mail.gmail.com.


Re: Having trouble writing a simple grouped undo/redo

2019-08-18 Thread Edward K. Ream
On Sun, Aug 18, 2019 at 8:12 AM Brian Theado  wrote:

> I wrote some code to perform 2 node inserts. I added before/after undo
> commands and undo/redo of the individual operations seemed to work fine.
> But when I enclose the two operations in before/after changeGroup, then
> redo doesn't work.
>

I'll take a look asap.  It may be a few hours, though.

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/CAMF8tS2vS-6J8sPSWi-cpEZ4fV7rz1WNwQ9y6ni1yg5coDPpmA%40mail.gmail.com.


Having trouble writing a simple grouped undo/redo

2019-08-18 Thread Brian Theado
I wrote some code to perform 2 node inserts. I added before/after undo
commands and undo/redo of the individual operations seemed to work fine.
But when I enclose the two operations in before/after changeGroup, then
redo doesn't work.

Does anyone know what I'm doing wrong?

To duplicate the issue:

   1. copy below xml to clipboard
   2. in a new leo outline ctrl-shift-c to paste as nodes
   3. highlight the "grouped insert redo test" node
   4. ctrl-b to execute it...two new headlines appear as expected
   5. ctrl-z to undo it...the two headlines disappear as expected
   6. ctrl-shift-z to redo it. The redo doesn't happen and the console
   shows this message:

redoGroup oops: expecting bunch.items.  bunch.kind = insert
redoGroup g.Bunch()
dirtyVnodeList: []
kind: insert
newBack: 
newChanged: True
newDirty: True
newMarked: False
newP: 
newParent: 
oldChanged: False
oldDirty: False
oldMarked: False
oldSel: (0, 0)
p: 
pasteAsClone: False
redoHelper: >
undoHelper: >
undoType: Paste Node


Here is the xml:



http://leoeditor.com/namespaces/leo-python-editor/1.1;
>


test redo
grouped insert redo test



@language python

undoType = 'insert first child twice'; u = c.undoer
parent = p.parent()
u.beforeChangeGroup(p, undoType)
undoData = u.beforeInsertNode(p)
child = parent.insertAsNthChild(0)
u.afterInsertNode(child, undoType, undoData)
undoData = u.beforeInsertNode(p)
child = parent.insertAsNthChild(0)
u.afterInsertNode(child, undoType, undoData)
u.afterChangeGroup(p, undoType)
c.redraw(child)





-- 
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/CAO5X8Cz%2BK%3DyzV3%2BQFErm%3D%3Dd5uc1ZfS580tyrjtiU_pnARDh9EA%40mail.gmail.com.