Undo Manager and CurrentEdit

I am trying to implement undo and redo. I have made subclasses of IGoUndoableEdit and want to add them to the “currentedit” of the undo manger. In the DocumentChanged handler of the view i handle the situation GoLayer.InsertedObject and make one of my IGoUndoableEdits and add it to the current edit and it works fine. I also do this for moving connection points. But when I delete multiple elements sometimes this.Document.UndoManager.CurrentEdit (still inside documentchanged) is undefined so I can’t add my IGoUndoableEdit to it. Do you know why this is? or what I could do to fix this? Thanks.

I don’t know the answer to your particular question. Usually you do that kind of work in a subclass of GoUndoManager (you have to put the code somewhere, after all, so it might as well be somewhere logical).
But I’m wondering exactly what you are trying to do. Do you have your own data structures whose state you are trying to manage for undo/redo? If you are just managing GoObjects, there’s no reason to implement your own IGoUndoableEdit classes. Even if you have inherited from various GoDocument or GoObject classes and added your own state, you don’t need to implement IGoUndoableEdit yourself-- you can just override GoDocument.ChangeValue or GoObject.ChangeValue to handle any extra Hints or SubHints that you define for your additional state.
And in the very common case where you don’t add any undoable state to any subclasses, you don’t need to override any methods – just set GoDocument.UndoManager to a new GoUndoManager, and everything should just work.

yeah i have my own data structures that need to have there undo and redo coincide with the godiagrams undo and redo. so i made the iGoUndoableEdits and want to add them to the current edit, but for some reason sometimes there is no current edit. thanks for the quick response.

I think GoUndoManager.CurrentEdit will be null after each outermost call to EndTransaction. (And after you call Clear() or set the property to null!)
Perhaps you have some document-modifying statements that are not within transactions? If you set GoUndoManager.ChecksTransactionLevel to true, there will be trace listener output each time there’s a document change outside of a transaction.