Any way to prevent language service "undo grouping" editing actions?

Hello,

The different language services in Visual Studio try to group distinct input events into undo groups. For example, if you type a space somewhere, move around the file, go back right after the just inserted space, and type another one, they will be "grouped". That means that when you try to undo, both typed characters will be 'undone' at once.

I would like to prevent this from happening (the issue is a bit more complex, because I open LinkedUndo's around each of the actions, but the language service still groups them and leaves me with "empty shell" LinkedUndo's after the fact).

I tried to open and close a CompoundAction both on the View and on the Buffer, but the language service is still able to ignore this.

Is there any way to prevent it? Any flag? Any "null" operation that won't do anything but will prevent the grouping?

Thanks,

- Jon
-
ViEmu - vi/vim emulation for Visual Studio

[1162 byte] By [JNG] at [2007-12-25]
# 1
I've resorted to opening a CompoundAction on the View, inserting and deleting a character at the beginning of the line through the Buffer, and closing the CompoundAction. The language service is not smart enough to jump over that. If this CompoundAction is open on the Buffer, it doesn't work fine.

A better fix would be welcome, but this is at least a solution.

It may have side effects that I'll discover in the future, but hopefully not.

Thanks,

- Jon
-
ViEmu - vi/vim emulation for Visual Studio

JNG at 2007-10-8 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...
# 2
The one way that could work would be to create the Undo actions yourself so that they would be nested within the automatic language service Undo action. It sounds like you are actually this already so it is probably the best work around you can have short of having access to the language service itself. Please do put a request through http://connect.microsoft.com/ to have this looked at in the next Visual Studio.
CarlBrochuMSFT at 2007-10-8 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...
# 3
Carl,

What I'm trying to do is to group several VS actions and actions from my plug in into a single undo group. Thus, the method you propose can't solve that.

I have tried implementing my own undo groups, but they cause the same kind of trouble as regular compound actions and/or IVsLinkedUndo. The language services simply aren't ready to work within external undo groups. Their design unnecessarily limits the usefulness of OLE undo grouping.

In the end, I have implemented a 'sentinel' undo action, and I insert that in the undo queue wherever I want to perform grouping. When undo/redo are done later, I walk the undo/redo stack and undo all actions until the sentinel. This is uglier, but it works with all language service quirks.

Best regards,

- Jon
-
ViEmu - vi/vim emulation for Visual Studio

JNG at 2007-10-8 > top of Msdn Tech,Visual Studio,Visual Studio Extensibility...

Visual Studio

Site Classified