Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for local history #26339

Closed
DZwell opened this issue May 9, 2017 · 66 comments
Closed

Add support for local history #26339

DZwell opened this issue May 9, 2017 · 66 comments
Assignees
Labels
feature-request Request for new features or functionality on-testplan timeline Timeline view issues timeline-local-history
Milestone

Comments

@DZwell
Copy link

DZwell commented May 9, 2017

I would love to be able to see my local history for a file like you can do in intelliJ.

@egamma egamma added feature-request Request for new features or functionality workbench labels May 10, 2017
@taseenb
Copy link

taseenb commented Sep 15, 2017

That would be amazing. Jetbrains has probably the best local history support. There are a couple of extensions for VS Code but they aren't as convenient.

@bpasero bpasero added workbench-editors Managing of editor widgets in workbench window workbench-history History item issues and removed workbench workbench-editors Managing of editor widgets in workbench window labels Nov 16, 2017
@alkorsan
Copy link

please add this option please
I m afried of Git, and this story make me more afreid of using it.

THIS THING DELETED 3 MONTHS OF WORK!!!!
#32405

single programers we don t need all the git complexity.

@MarekJavurek
Copy link

+1 (just few mins ago, wanna discard some changes in just few files... discarded all unstaged files...)

@nancycg
Copy link

nancycg commented Jun 13, 2019

Can anyone please suggest - "How can I see my local file history changes in VS code like we can check in eclipse IDE? Sometimes we do changes a lot in single file before commit and this feature can be really handy to check entire day's changes in one file. I have checked few plugins like "Local History" but the changed files keep on adding in my git changes section and changed file numbers keep on increasing. I doubt if I am using it correctly. Please suggest best plugin or options for it. Thanks

@jabacchetta
Copy link

jabacchetta commented Jul 22, 2019

For reference, there is an extension, but it's not nearly as powerful as what's offered in IntelliJ/WebStorm.

Examples of features that I'd like to see if this were to be implemented:

  • Being able to add checkpoints (local commits). This is the IntelliJ equivalent to adding tags to your history. There is another extension for that here, though.
  • Being able to support local history when the files are moved/renamed.
  • Being able to revert more than just edits (e.g. deletes, moves).

This feature set also has synergy with #43555, #52844, and #9390.

@faldor20
Copy link

This is something that would be super helpful. even just to be able to save undo across sessions would be amazing.

@andrecasal
Copy link

andrecasal commented Oct 4, 2019

Here's a horror story. I had all my files tracked in Git and began writing code for a new feature that used an API at the end of a file, so my workspace had uncommited changes. Because I had to wait for approval for more API quota to continue developing and testing my code and because my code wasn't yet commit worthy, I continued work on other projects and forgot I had uncommited changes in that repository.

A few days later I was experimenting with some VS Code features and I needed to purposefully create some linting errors in a file to test it out, so I opened that same repository and randomly deleted a few lines at the top of the file I had been working on a few days before. I mistakenly thought I could just "discard changes" in the Source Control tab and Git would bring my file back, reinserting the lines I deleted. I closed the file, losing the ability to undo (cmd+z) the deleted lines. As I was ready to reverse the deleted lines, I hopped onto the Source Control tab and only seeing the deleted lines at the top of the file (I did not look at the Ruler on the right hand side to see I had more uncommited changes), I pressed "Discard Changes".

A few days later my request for API quota was approved and I reopened the file. As I scrolled to the end of the file my jaw dropped and I started replaying this cute little story in my head, trying to understand out how the hell had I figured out a way to permanently delete my own work.

TL;DR
Local history would have saved me from having to spend a few minutes (but it could have been hours or days) rewriting permanently lost code.

I would love an ETA on this feature and a comment on what's blocking it from being shipped.

@kpalatzky
Copy link

I would love this feature! 😍

@thealexwilson
Copy link

+1

@leevare
Copy link

leevare commented Mar 26, 2020

This feature is useful

@bilel-bj
Copy link

bilel-bj commented Apr 2, 2020

Any update about this feature

@mbranicky
Copy link

+1

@teosbb
Copy link

teosbb commented Jun 2, 2020

Today i stopped using VS Code after 4 years and switched to IntelliJ. THIS IS THE REASON WHY. I love VS Code, but a editor without local history is gabrage.
I just lost 30 file of refactoring because a commit issue - probably wasnt VS Code(probably husky), but it leaks local history.

@nancycg
Copy link

nancycg commented Jun 2, 2020

VS code should add this feature ASAP otherwise sooner or later, developers find other IDE to work Because we all do mistakes and high chances of losing our work in the absence of this feature.

@wizofaus
Copy link

Team Explorer does let you view history for any changed files, but I don't see how to use it for a file that hasn't been changed...

@seth100
Copy link

seth100 commented Mar 17, 2022

Great news, thanks for that! Just a curiosity: what's the filesystem location of the files that are created to keep that history? And, is there a way to keep it clean at some point (either manually or automatically)?

@avgspacelover
Copy link

I wanted to learn how to build that :(

@aliuq
Copy link

aliuq commented Mar 17, 2022

Great news, thanks for your work, I just tried it out and it met my expectations, which is going to be my favorite feature.

Can I make some suggestions? when comparing previous version with current, Could support fast append block content to another?

image

Thanks again.

@bpasero
Copy link
Member

bpasero commented Mar 17, 2022

@antariksh17 sorry for that. this was a rather involved change, but I am happy to answer any questions that you might have for how I added this via #145136. Typically I would try to look for issues that have the related label applied for where we ask for help, please see https://github.com/microsoft/vscode/wiki/How-to-Contribute#where-to-contribute

@seth100

what's the filesystem location of the files that are created to keep that history? And, is there a way to keep it clean at some point (either manually or automatically)?

That depends on how VSCode is run:

  • local desktop client with local workspace: local file system
  • local desktop client with remote file system backed workspace: remote file system
  • web client with remote file system backed workspace: remote file system
  • web client with non-file-system-backed workspace (e.g. vscode.dev): IndexedDB in the browser

When stored in the file system, there is a folder called History in the folder User that is stored at the user-data-dir, which depends on the OS you are on. That is the same location where e.g. also backups go or UI state.

As for cleaning up:

  • entries can be manually deleted one by one from the timeline view
  • oldest entries are automatically removed when the configured limit is reached
  • there is a command to remove all entries across all files:

image

Not sure you are missing another way of cleaning up entries?

@aliuq

Can I make some suggestions? when comparing previous version with current, Could support fast append block content to another?

Please cast your vote at #25887

@badrelmers
Copy link

@bpasero Thank you very much for your excellent work.

I made a feature request here
Timeline - save the backup file relative to the original file
#145321

I have two more requests, but I could not open a new ticket (github gave me error 500!), so I will post them here:

Timeline - lists all the files which are saved in the backup folder
I hope we can have an option to see all the files which are saved in the History folder, so we can cleanup orphan files and have a summary of our history timeline.
orphan files = when I delete or rename a file, its backups will remain in the History folder inside user-data-dir folder.

Timeline - track renamed files
when I rename a file inside vscode, its timeline is lost. I hope it can be tracked when renamed so it keeps the same timeline.

thank you.

@bpasero
Copy link
Member

bpasero commented Mar 17, 2022

Timeline - lists all the files which are saved in the backup folder

The command "Local History: Find Entry to Restore" gives you a list of every file that has local history entries. From there you can drill into the individual entry. If you have the "Timeline" view visible, you can delete individual entries. I know this is a bit rough from a UX point of view and I think #95332 needs to land in order for the timeline view to show the full set of all local history entries.

I am open for suggestions how to improve the "Find Entry to Restore" picker. It would be easy to add a button into the picker to remove entries from the picker.

Timeline - track renamed files

Yeah, that is on my list to look into, if I cannot get to it, I will file an issue for it.

@badrelmers
Copy link

@bpasero

The command "Local History: Find Entry to Restore" gives you a list of every file that has local history entries.

cool, I did not know that this option keeps track of deleted/renamed files too, nice.

I am open for suggestions how to improve the "Find Entry to Restore" picker. It would be easy to add a button into the picker to remove entries from the picker.

yes a button to remove an entry will be useful, or maybe a button to open the folder where the backup of a specific file resides, which will serve for other purposes (like deleting the content or do a grep search), because actually the folders names inside History folder use a hash, and it is impossible to decrypt that hash because of the Bitwise left shift used I think.

@bpasero
Copy link
Member

bpasero commented Mar 17, 2022

Yeah, so the location of a history entry is actually a hash of the full original path so that we have a fixed-length unique location for each file. Within the location, each entry is a random 4-length name with the original extension. As a sibling there is a entries.json file that contains the original file name and some metadata, e.g.:

{
   "version":1,
   "resource":"file:/Users/bpasero/Desktop/project/file.ts",
   "entries":[
      {
         "id":"4oXJ.json",
         "timestamp":1647520366982
      },
      {
         "id":"DEnq.json",
         "timestamp":1647523809834
      },
      ...
   ]
}

Feel free to file individual issues for the things you ask for, then we can proceed in those issues and discuss them there.

@bpasero
Copy link
Member

bpasero commented Mar 21, 2022

We will ship this feature as part of our April release next week. You can use our insiders builds to benefit from the feature today: https://code.visualstudio.com/insiders/

The test plan item #145461 covers its capabilities, so feel free to give it some testing and report issues back.

Some new things added over the past days:

  • track renames of files that are under active local history
  • a new setting workbench.localHistory.mergePeriod to merge entries over a specific period of time
  • a more prominent filter action in the timeline view to enable/disable local history entries (or git entries)

Existing issues are labeled timeline-local-history

@bpasero bpasero closed this as completed Mar 21, 2022
@bpasero
Copy link
Member

bpasero commented Mar 21, 2022

If anyone has a better idea for how to call the workbench.localHistory.mergePeriod setting, feel free to reach out:

image

The way it works is:

  • you save and immediately a local history entry is created (so it is not a delay or timeout)
  • any new entry that is within 10s to the last entry will replace that entry (so it is more like a debounce)

Some suggestions so far from the team are to call it frequency or debounce.

@jonlepage
Copy link

call it frequency or debounce.

interval also !
and more synonyme !
https://www.thesaurus.com/browse/frequency
https://www.thesaurus.com/browse/interval
https://www.thesaurus.com/browse/delay

@bpasero
Copy link
Member

bpasero commented Mar 22, 2022

Yeah that site is really helpful, I use it a lot. I think interval might be a bit misleading because as a user you might think that now a local history entry is created every 10s even without user action. For example setInterval in JavaScript installs a function that will run every <n>ms.

@andrecasal
Copy link

I vote for debounce for the sake of accuracy. Interval, frequency, and delay don't really capture what it is.

@bpasero
Copy link
Member

bpasero commented Mar 22, 2022

Another idea I had was mergeWindow. window seems to describe a time span and so merge would occur in a certain time span.

Though window is a bit of a overloaded term, especially in an application that has a lot of window UI settings.

@badrelmers
Copy link

I vote for the word merge too. how about mergeChanges

@bpasero
Copy link
Member

bpasero commented Mar 22, 2022

@badrelmers the setting itself is a number as seconds though, so I would like to have some kind of reference to time in the settings key.

@badrelmers
Copy link

badrelmers commented Mar 22, 2022

yes. then why not mergeChangesInterval?

@andrecasal
Copy link

A few more suggestions:

  • saveDebounceInterval <- my current preference
  • mergeDebounceInterval

@jacrosby
Copy link

It seems to be impossible to go back to the old behaviour, which is to have a single timeline item called "uncommitted changes". This makes it very hard for me to see what I have changed since the last pull, without painstakingly going through each individual timeline item and memorising the full diff between each version.

Storing local history is very useful, but could we have a switch to easily toggle between showing:

  • All individual local saves
  • All uncommited changes together (i.e. merged)

Turning off the new local history feature in workspace settings seems to show just the git timeline without any information about uncommitted changes.

@bpasero
Copy link
Member

bpasero commented Mar 31, 2022

Uncommitted changes are accessible from the SCM changes view:

image

The decision to remove the entry from timeline was discussed in #145723

@jacrosby
Copy link

This should be something you can toggle between. And if you turn off local history then it should definitely still be shown.

@Chealer
Copy link

Chealer commented Mar 31, 2022

Uncommitted changes are accessible from the SCM changes view:

I did not test the proposal, but it would be useful to tag history entries in relation to SCM. If the latest committed state was flagged, that would facilitate the use case of @jacrosby (as long as that entry is still in history...)

@bpasero
Copy link
Member

bpasero commented Mar 31, 2022

There is currently no relation between SCM entries and history entries, they are 2 independent providers of timeline entries.

@nidefawl
Copy link

nidefawl commented Apr 4, 2022

I want to thank everyone involved so much for this feature.
Last week I was able to recover 3 days of work after hitting delete on samba share directory that contained a symlink. photorec and ext4magic couldn't restore the files from my ext2 fs partition.
I figured its all gone when I did a final grep through the vscode-insiders-server folder and found the all of the code in perfect condition. I was so happy!

@github-actions github-actions bot locked and limited conversation to collaborators May 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality on-testplan timeline Timeline view issues timeline-local-history
Projects
None yet
Development

No branches or pull requests