I have a Visual Studio (2010) package that combines multiple text operations, e.g. it inserts custom properties into my csharp files.
These inserts can become quite numerous and I would like to be able to reverse the effect of the Command with a single click of the undo button. Is there a way of doing this?
Yes. Assuming you have a valid
You just need to get an ITextEdit, like this:
Then you can:
and when you are done, you must
or
If you don’t apply or cancel your changes, other changes will not be allowed on the buffer…. so you probably want to wrap your changes in a try…finally so an exception doesn’t shut down your editor. All your changes will be grouped and a single undo will reverse them all.
Hope this helps.