nesting not working

Apr 17, 2009 at 7:11 PM
I also posted this on the blog, but wanted to post it here too in case it's checked more frequently.  Sorry for the duplication.

I tried nesting, which the blog indicates is supported, as follows:

using (UndoRedoManager.Start("x"))

using (UndoRedoManager.Start("y"))

The second "Start" call throws an InvalidOperationException, saying:

"Previous command is not completed. Use UndoRedoManager.Commit() to complete current command."

I am using a version downloaded from CodePlex, "Beta 1", from the "Sources" download, and using the "Release" dll within that.

The blog seems to indicate that this should work.  Is there a later version that supports nesting? Or am I doing something wrong? Thanks.
May 7, 2009 at 11:39 AM
I have verified the code again. Unit tests for nested commands work fine. Tests are using the source code that is very similar to yours.

Most likely you have problems on your side.

You could do following:
- make shure that you have up-to-date Release folder -- try to remove it and recomple the project.
- try to run unit tests (DejaVu.UnitTests \ UndoRedoManager \ NestedCommandsTests.cs)

Hope it will help.
May 7, 2009 at 11:52 AM
I also find out that exception can be thrown if nested command is empty. In other words, if nested command 'y' does not change any undo/redo property, it will not be commited. Consequently, parent command 'x' can not be commited too and will failed.

So, in your case I suppose that Thingy propperty is not undo/redo property. It is regular property. Thats why 'y' is treated as empty command and commit failed eventually.

I will fix this behaivior. I think empty commands should not cause any exceptions.

Thank you for feedback