I suggest you ...

Exclude outlining operations from the undo/redo stack

There's something really annoying in Visual Studio : where 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... Please, don't record outlining operations, or at least make it optional!

416 votes
Sign in
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Thomas Levesque shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →


    Sign in
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      • nivan commented  ·   ·  Flag as inappropriate

        I even can't imagine any use case for this weird "feature"? Quite contrary, this completely ruins any normal editing cycle - you do changes, browse code doing folding/unfolding and now your undo stack is full of garbage - press ctrl+z 123 times to undo a change. Feature by a sheer genius! ;)

      • Rick Sladkey commented  ·   ·  Flag as inappropriate

        I discovered with a little poking around that there is in fact an option to turn this off, and it does work, but it does not seem to be exposed anywhere in the UI. Someone could write a Visual Studio extension that would turn it off automatically.


      • Andri commented  ·   ·  Flag as inappropriate

        This is hands down one of the dumbest features I've ever known of in an IDE.

        Why would you put a display change on the undo stack???

      • Bachowny Plamborgs commented  ·   ·  Flag as inappropriate

        Please do this. I'm not surprised that people are annoyed at this, but I'm really surprised this issue is still open after nearly 5 years.

      • Richard Braint commented  ·   ·  Flag as inappropriate

        The other comments pretty much cover it - if any one was listening.
        This is a BAD design choice - get rid of it.

      • Tom commented  ·   ·  Flag as inappropriate

        Very much want to see this behavior gone. Agree with earlier comment that outline changes are nothing to do with the "model" - it is a "view" matter and should be kept separate from undo/redo history by default. Too many times I've had to make a backup of my file and diff a save to trust that I didn't mess something up. I shouldn't have to do this - undo should immediately go to the last *change* to the file, then I'd trust the editor again!

      • Ron Little commented  ·   ·  Flag as inappropriate

        This behavior is very annoying. I frequently use undo-redo as a quick way to get my cursor back to where I was editing within a large document, and expanding/collapsing regions makes this process confusing and takes more keypresses. Please make this undo/redo behavior optional.

      • ultim8f8 commented  ·   ·  Flag as inappropriate

        Imagine this use case: Renaming something using find/replace. Now this operation, if you've never used it, will affect code inside collapsed blocks. So if I go to expand those blocks to check that the rename didn't break the world, when I ctrl+Z to see the unmodified code, it just recollapses the block! WTF! How does this make ANY sense?!?

      • Martin commented  ·   ·  Flag as inappropriate

        VS team: removing this ridiculous "feature" will save lives. Besides, it probably involves >removing< a couple lines of code. Please do it already.

      • Jel Gab commented  ·   ·  Flag as inappropriate

        VS team: Not paying attention to this makes one think that you are disregarding the users. If you consider that this is a needed "feature", at least provide the option to disable it. Source Control and other workarounds help but that doesn't mean that this problem may now stay forever.

      • Pravin Chaudhary commented  ·   ·  Flag as inappropriate


        Whoever developed this (either intentionally as a *cool* feature, or a bug)

        Please understand MVC. Model View Controler.

        Expand/collapse region are actions that affect the view, not the model.

        Undo/redo are supposed to record changes to the model, not to the view.

      • AllanX commented  ·   ·  Flag as inappropriate

        At this point I can't fathom how many cumulative hours of work I've lost to this ridiculous behavior over the years. How damning is this: I've taken to making safety copies of my code as I work into another text editor because I simply can't trust Undo and Redo in Visual Studio not to destroy hours of my work.

        It's hard to describe how easy it is to get completely lost when trying to undo a long series of edits in Visual Studio; how endangered your code is when doing this. I'd love to hear the rationale behind it. I mean, if you're going to put collapse and expand regions which aren't actual changes on the undo stack, why stop there? Why not put every cursor move and page up and page down on it, too. I don't know what's more crazy, the fact that this behavior ever existed in the first place, or that it STILL hasn't been addressed.

      • JP commented  ·   ·  Flag as inappropriate

        This is so annoying! I didn't lose a lot of code by chance, but I just don't want that to happen anytime soon. Please at least make it an option to include or exclude outlining operations from the stack. Thank you.

      • Maxime Rossini commented  ·   ·  Flag as inappropriate

        Same as everyone here, the problem is not the redundant need to call ctrl-Z twice but the fact that the redo stack is cleared as soon as a region is expanded (say, to copy some hidden code you deleted in your redo stack...).

      ← Previous 1

      Feedback and Knowledge Base