2

Case 1 (Overwritten undo/redo history)

  1. You are editing source codes on "Program.cs". After a dedicated hour, You've done with 100 lines and typed "Ctrl+S"(Save).
  2. To take a break, you left your desk without closing the "Program.cs" and Visual Studio. While you're leaving, your dog came to your desk and typed sequently
    "Ctrl+Z"(Undo) > "Ctrl+Z"(Undo) > ... (Until the original codes appered) > "a"(Type text).
  3. You came back from a break but it's too late. You're pressing "Ctrl+Z"(Undo) or "Ctrl+Shift+Z"(Redo) to recover your 100 lines, but all you can get is the original codes or "a".

Case 2 (Discard undo/redo history)

  1. You are editing source codes on "Program.cs". After a dedicated hour, You've done with 100 lines and typed "Ctrl+S"(Save).
  2. To take a break, you left your desk without closing the "Program.cs" and Visual Studio. While you're leaving, your dog came to your desk and typed sequently
    "Ctrl+A"(All) > "a"(Type text) > "Ctrl+S"(Save) > "Ctrl+F4"(Close the src).
  3. You came back from a break but it's too late. You're pressing "Ctrl+Z"(Undo) or "Ctrl+Shift+Z"(Redo) to recover your 100 lines, but all you can get is "a".

What i want to say through the above cases is "It's quite easy to lose the 100 lines."
I knew those possibilities and believed that i'll never catch of them, but the Second Case just happened 30 minutes ago by own mistake.

I want to know whether any solutions exist except SVN/GIT commit and rollback features.
Unfortunately, "Undo/Redo Last Global Action" didn't work for me.

Thank you for your help.

dosuken123
  • 438
  • 3
  • 7
  • 19
  • 3
    Case 1 is simple - just reload the file. (You haven't saved, right?) For case 2, you appear to have a pretty impressive dog, who is able to hit Ctrl-S and Ctrl-F4. In short, could you give a more *realistic* situation where you're losing work? I don't think this is really "quite easy" at the moment... – Jon Skeet Sep 06 '16 at 08:21
  • @JonSkeet Thank you for your advice. But, please assume Case 1 is going to be saved after the process. As i wrote Case 1 means when "Overwritten undo/redo history" happened. In addition, please focus on the steps, but the dog. For example, In Case 2, I'm afraid of just 4 magical steps can blow your codes away, but ... is it inevitable? – dosuken123 Sep 07 '16 at 01:31
  • If you intended case 1 to include saving, why didn't you add it there? I suggest you do so now. It still all sounds unlikely to me. If this really happens to you frequently, it sounds like you need to commit to source control more often. – Jon Skeet Sep 07 '16 at 05:41
  • @JonSkeet Thanks again. Terje Sandstrøm 's answer seems to be a better solution for those cases. – dosuken123 Sep 07 '16 at 06:13
  • 1
    I'd say the best solution is actually to keep your dog away from your keyboard. If the dog is capable of doing so much damage just within Visual Studio, imagine what it could do to your email, internet banking etc. – Jon Skeet Sep 07 '16 at 06:24

2 Answers2

2

You asked for VS2010, but tagged this also for VS2012, and for VS2012 and onwards you have the Microsoft Devlabs AutoHistory extension which tracks local history. The extension is here: https://visualstudiogallery.msdn.microsoft.com/dfcb2438-180c-4f8a-983b-62d89e141fe3 , a blog on it is here: https://blogs.msdn.microsoft.com/visualstudio/2014/01/23/auto-history-extension-in-visual-studio-2013/

Example screenshot, the diff produced for a file where I added a Subtract method, saved it, then my dog came around and wiped it off and wrote "bbbbb" instead. enter image description here

Terje Sandstrøm
  • 1,979
  • 15
  • 14
  • Even though it's the solution for VS2012 or later, it is brilliant. I hope every single IDE has this feature. – dosuken123 Sep 07 '16 at 01:48
  • This is DevLabs work, so an update may or may not be upcoming. There is a hack described in the review for it, https://marketplace.visualstudio.com/items?itemName=VisualStudioPlatformTeam.AutoHistory#review-details, which is easy to do, and it works. It is at least a workaround until something happens here. – Terje Sandstrøm Jan 26 '19 at 12:24
0

CTRL Y - Is the easiest way to fix the problem in visual studio code.