For anyone that uses emacs, there is an excellent plugin "undo-tree" that solves this problem in a slightly different way. Everytime you undo a series of actions and then perform a new action, it creates a branch in the "tree". You can then visualize the tree and move through it quickly your entire buffer history.
Newb emacs user here. Heavily reliant on spacemacs and tutorials and copy-paste, but I use it often. The undo-tree terrifies me.
Why is it so hard to see code from 5 minutes ago?
81–90 of 424 posts
Re: Why is it so hard to see code from 5 minutes ago?
#82Reading the comments, I'm stunned and disillusioned. Are most modern developers struggling to write code without this? If so, there is a fundamental problem that has nothing to do with levels of undo.
Re: Why is it so hard to see code from 5 minutes ago?
#83Earlier quoted context omitted.
This is excellent... for Vim users. A lot of developers either are not willing or haven't gotten around to learning the complexities of Vim, and use other IDEs like JetBrains or Eclipse. This workflow won't work for them.
I am one of those "not willing" people. I encounter the same issue discussed here without even thinking about it, and solve it as such: 1. Realize I need to check how my new code looked like 5 min back. 2. Copy full file into clipboard, undo by a few steps 3. Do a temp commit on GitHub desktop 4. Paste the new code back and look at the diff on GitHub desktop, and if needed undo the temp commit from above. Is this mor…
But if code is your way of life, which it is for many people here, it is beneficial to learn the tools that allow you to do it easier. If someone can see how their code was 5 minutes ago in a few keystrokes, they’re going to take advantage of that significantly more frequently than someone using your cumbersome method.
Re: Why is it so hard to see code from 5 minutes ago?
#84Does anyone know if there’s a good way to do this in VS Code? I often hold cmd-z until I get to some version and copy code from it. Ideally I’d like to have a separate window where I can see a previous version without affecting the current file/view. Before anyone comments, git doesn’t cut it for this because no one commits after every -+1
Commit early, Commit often!
Re: Why is it so hard to see code from 5 minutes ago?
#85Earlier quoted context omitted.
This was my first thought. A timeline is nice, but the problem with a linear undo history is that if you undo and then edit, you lose access to the state before you undid. A tree is clearly the right structure for undo history.
You could just append a new state to the end of the timeline when you “undo”, so you never lose history. This is how undo works in Emacs by default.
Re: Why is it so hard to see code from 5 minutes ago?
#86Does anyone know if there’s a good way to do this in VS Code? I often hold cmd-z until I get to some version and copy code from it. Ideally I’d like to have a separate window where I can see a previous version without affecting the current file/view. Before anyone comments, git doesn’t cut it for this because no one commits after every -+1
It might not be exactly what you're looking for, but I saw this linked on Twitter recently and have been meaning to try it out, so maybe worth a look? https://marketplace.visualstudio.com/items?itemName=Wattenbe...
Re: Why is it so hard to see code from 5 minutes ago?
#87Earlier quoted context omitted.
I certainly don’t commit things every five minutes, so this doesn’t help.
(Ok, looking at your profile and your background, I must be missing something. You surely don't need 5 or 10 minute history of code to know what you are doing.) Please help me understand what I am missing from this conversation!
This seems to be a fine example of that.
(Though I must admit that consternation about how often someone presses Ctrl-Z is a bit lower level than I’m used to seeing.)
Re: Why is it so hard to see code from 5 minutes ago?
#88Idk I do think version control is probably a much better tool to sanely manage rapid workflow when working at scale on huge projects, I just think the problem is that there too many features and far to few people who actually take the time to learn how to use them effectively.
To prove my point, the awk tool is super powerful and solves many "quality of life" problems developers begrudgingly deal with on a daily basis over and over again.
Now lets see a raise of hands of people in here that can actually write an awk script one liner without referring to the manual?
We have all these wonderful tools but most of us are too spoiled by having a mouse and powerful editors that we don't ever learn how to use them to improve our performance as developers.
Re: Why is it so hard to see code from 5 minutes ago?
#89> I'll walk through some reasons why version control does not save the day here. While a developer is making changes to code, they may not realize that they want some intermediate version from a few minutes ago until they are well into making the change and become stuck. We saw this repeatedly in our studies. This introduces a problem of premature commitment3, which forces the developer to decide to save an intermedi…
Low-level plumbing commands, if the VCS has them, can help with that, e. g. `git commit-tree`.
Re: Why is it so hard to see code from 5 minutes ago?
#90Earlier quoted context omitted.
Committing removes the diff view in PyCharm, and I can't lose that. By "diff view" I mean I can see all the changes I've done from the main branch.
Personally, when I'm ready to submit a pull request, I usually do a soft reset to the point where I branched off from, then redo my commits and force push to the branch, for exactly that reason. I can't remember exactly which lines I've changed over the past few days unless I see all the diffs together.
I suppose I can stash my current code, reset to where I started somehow, and then unstash.
I've also toyed with the idea of having two repos on my disk.