Live data from Hacker News

Why is it so hard to see code from 5 minutes ago?

web.eecs.utk.edu

71–80 of 424 posts

Re: Why is it so hard to see code from 5 minutes ago?

#71

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.

For those that use vim, gundo.vim visualizes the "undo-tree" and allows you to preview / jump to any revision: https://github.com/sjl/gundo.vim

Re: Why is it so hard to see code from 5 minutes ago?

#72

Does 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

this looks like it does that https://github.com/zabel-xyz/local-history

not super polished nor is it actively maintained but has promise

Re: Why is it so hard to see code from 5 minutes ago?

#73
post #42

Earlier quoted context omitted.

That's what a git browser is for. It's not like your code is gone forever, unless you are undisciplined.

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!

Re: Why is it so hard to see code from 5 minutes ago?

#74
I routinely use copypasta and a quick rename as basically a stash/throwaway commit without breaking editing flow. It doesn’t stick around til a real commit because my tools yell about unused references. But it lets me keep and cross-reference a previous approach without undo history or going into version control mode when I’m exploring options.

Re: Why is it so hard to see code from 5 minutes ago?

#75

Does 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?

#76
post #27

Earlier 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.

JetBrains' various apps can do this as well with a feature called "Show Local History". I'm not sure where it is in the menus but you can hit shift twice and type it in. It automatically commits after every change since the IDE was opened, and can easily be diffed and reverted as needed. Reverting saves another entry, so you can revert back to the future as well.

This. I've seen developers _think_ they lost code in Android Studio and spend hours trying to recreate it when it was in local history all along...

Re: Why is it so hard to see code from 5 minutes ago?

#78
post #10
post #7

Earlier quoted context omitted.

When I looked, it had the same problem that Dropbox has with this: a textual listing with only timestamps. I need semantic info! Show me the differences. Don't make me choose from this arbitrary list. I want to scan through the versions very, very quickly.

Not sure what you're looking at, but IntelliJ 2020.3 gives me a list w/ timestamps in 1/3 of the modal, then a diff viewer in the other 2/3. I can down-arrow through the versions and the diff updates.

That's the way it's been for years.

Re: Why is it so hard to see code from 5 minutes ago?

#79

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.

Tangentially, have you had the issue where undo-tree just uses a ton of memory and makes everything unusable?

Re: Why is it so hard to see code from 5 minutes ago?

#80
post #27

Earlier 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.

JetBrains' various apps can do this as well with a feature called "Show Local History". I'm not sure where it is in the menus but you can hit shift twice and type it in. It automatically commits after every change since the IDE was opened, and can easily be diffed and reverted as needed. Reverting saves another entry, so you can revert back to the future as well.

IIRC you can right-click on the column with line numbers to the left of the main editor and you'll have that option too
Post reply on HN