Undo and OnCodeSnippetFieldDeactivating

SyntaxEditor for Windows Forms Forum

Posted 18 years ago by Ashton - Developer, Schema Solutions LLC
Avatar
I have an issue where I invoke a snippet and then immediately after invoking a call Undo on the document and the problem I get is that in the OnCodeSnippetFieldDeactivating for this snippet I am replace the text the user entered with some generated text and it seems to be getting into an infinite loop and eventually generates a StackOverflow exception (when I try to set the text using SelectedView.ReplaceSelectedText it invokes the OnCodeSnippetFieldDeactivating event again)

Is there a way in the event to tell that an Undo action is happening and not to do anything?

Comments (3)

Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Unfortuantely no, there could be many things that cause the OnCodeSnippetFieldDeactivating event to fire, the biggie being the SelectionChanged event.

What if you wrapped your call with a boolean flag like: quit if flag is set to true, set flag to true, call replace, set flag back to false.


Actipro Software Support

Posted 18 years ago by Ashton - Developer, Schema Solutions LLC
Avatar
I actually tried that immediately after posting the message, doing:

if (bAlreadyHere)
return;
bAlreadyHere = true;
try
{
...
}
finally
{
bAlreadHere = false;
}

And when I did that, the function did work but it placed some weird characters at the end of the text and when I went to delete them the entire editor was replaced with a big red X (usually indicating Paint method failed I think)

I'll try to do it at a higher level and see what happens so that I don't even go into Deactivated if the user pressed Undo/Redo.

Thanks
Posted 18 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Ok and if you still find you have weirdness going on, then perhaps you can send over a simple sample showing this that we can debug.


Actipro Software Support

The latest build of this product (v25.1.0) was released 26 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.