Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio : exclude outlining from undo/redo stack

There's something really annoying in Visual Studio : when I expand or collapse a method or code region, this action is pushed on the undo stack. So if I edit some code in a method, then collapse that method, and then want to undo my change, I have to undo twice : once for the collapse action, and once for the change in code. This can be VERY confusing if you expanded or collapsed several things after editing the code, the editor keeps jumping to different places and you don't know whether your changes have been undone or not...

So my question is : is it possible to disable that behavior ? i.e., that only changes in code are taken into account in the undo stack ?

PS: I'm using Visual Studio 2008


If this behavior annoys you too, please vote to fix it on UserVoice!

like image 684
Thomas Levesque Avatar asked Nov 29 '09 23:11

Thomas Levesque


People also ask

How do I stop outlining in Visual Studio?

For VS2008, it's under Tools – Options – Text Editor – C/C++ - Formatting - Enter outlining mode when files open. Show activity on this post. Then under > Outlining , set Enable Outlining to False.

How do I turn off Ctrl Z in Visual Studio?

From the Visual Studio's Edit menu. Clicking the undo and redo icons on the toolbar. Pressing CTRL+Z for undo and CTRL+Y for redo.

How do I undo in stack?

When user want to undo those operations, simply pop operations from the "performed" stack to a "recall" stack. When user wants to redo those operations, pop items from "recall" stack and push them back to "performed" stack.

How do you undo a step in Visual Studio?

So, if you've just taken a step in live debugging (F10 or F11), you can use the Step Backward button to quickly navigate to the previous step. This will automatically put Visual Studio in Historical debugging mode, at the line of code you've stepped back to.


2 Answers

I've created the Disable Outlining Undo extension that excludes expanding and collapsing operations from recording to the undo/redo stack in Visual Studio 2017/2019.

Thanks to Rick Sladkey for the idea!

like image 59
Sergey Vlasov Avatar answered Sep 23 '22 15:09

Sergey Vlasov


I did a little poking around and discovered that there is in fact an option in Visual Studio to disable this behavior, and yet it does not seem to be exposed anywhere in the user interface. However, you can set it programmatically, and I tested that it does work, so it is (technically) possible.

The options is:

DefaultTextViewOptions.OutliningUndoOptionId

and you set it like this:

textView.Options.SetOptionValue(DefaultTextViewOptions.OutliningUndoOptionId, false); 

With this information a very simple Visual Studio extension could be written to toggle this setting for all new ITextView instances.

like image 25
Rick Sladkey Avatar answered Sep 19 '22 15:09

Rick Sladkey