alefragnani / vscode-bookmarks

Bookmarks Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=alefragnani.Bookmarks
GNU General Public License v3.0
1.7k stars 163 forks source link

[BUG] - Where are bookmarks stored? Seems mine have disappeared! #354

Closed mikeerickson closed 3 years ago

mikeerickson commented 3 years ago

Just went to use a previously saved bookmark and it seems they are all GONE!

Where are the bookmarks stored? I am going to check a backup drive to see if I can restore what was there.

This has happened to me a couple different occasions, last time I only had a few, but this time I had about 15 or so đź‘Ž

Version: 1.52.0-insider Commit: ee46c1f89ebb213e0827886f1688c0fbb55be49f Date: 2020-11-13T06:04:37.031Z Electron: 9.3.3 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0 OS: Darwin x64 19.6.0

mikeerickson commented 3 years ago

This has happened yet again, and at this point I don't have confidence that it wont happen in the future.

fade2gray commented 3 years ago

@mikeerickson

Sounds like you may have renamed or moved the file that you had added bookmarks to, in which case the bookmarks won't follow the file but the file name will remain in the Bookmarks sidebar tree-view - If you restore the name/location of the file they will return.

Bookmark details, amongst other data, is stored in a database file called state.vscdb, if wich you may find several in the subdirectories in C:\Users\<UserName>\AppData\Roaming\Code\User\workspaceStorage\ (Win OS).

To transfer the bookmarks to renamed/relocated file, you would need to use a search tool to search all the state.vscdb files for the original filename and then use a database browser to edit the file name and/or path.

Not a simple task - good luck.

References: #80 #209

mikeerickson commented 3 years ago

@mikeerickson Nope, not in this case. The filename has been the same for quite sometime and the location has never changed since first created. Where are these files located on macOS?

I have given up hope that my previous bookmarks will return, but I am going to make sure they are at least backed up so should this happen yet again, at least I have a chance of restoring them

mikeerickson commented 3 years ago

What is really bizarre, I just rebooted VSCode after installing some extension updates, and a brand new bookmark has appeared in a file which I have never added a bookmark. Something is VERY wrong here.

Do you know of a way I can trash all existing bookmarks so that I can start fresh? What happens if I uninstall the extension and then reinstall? I am assuming bookmarks will be retained should I perform these operations

fade2gray commented 3 years ago

Could be a corrupt db file, though I expect @alefragnani will offer a better explanation.

To clear bookmarks from the explorer view...

BookmarksClear

mikeerickson commented 3 years ago

Well let’s hope @alefragnani responds at some point. I will await more info before I try using again.

alefragnani commented 3 years ago

Hi @mikeerickson ,

Sorry for the delay. I was ready to participate yesterday, but had some issues with other projects and couldn't answer.

About the location where the bookmarks are stored, @fade2gray is correct. The extension uses VS Code workspace storage API, which stores this data in VS Code internal locations. Originally, this was show in Local Storageon Developer Tools (because VS Code/Electron is in fact, Chrome). But a few years ago, the VS Code team moved to this files in disk. But, you also have the option to save the bookmarks with your project. If you do this, the bookmarks are stored in .vscode/bookmarks.json. Unfortunately, this options does not support multi-root workspaces, yet.

Back to you original issue, I don't remember specific issues about loosing bookmarks, at least nothing related to crashes or something like that. On the other hand, I see two scenarios where the bookmarks could appears to be lost:

  1. If you use formatters, like Prettier: Formatters don't report changes like normal user editing, and I still have to properly handle it. It was originally reported in #118 , and I added a workaround setting to fix it.

  2. If you changed/renamed files: This issue will be fixed in today's release (12.0.0). Up until today, if you rename a file (inside VS Code) the extension wasn't aware, and you end up with ghost bookmarks (#209 ).

Bookmarks are saved per session/folder/project, which means that if you open the folder ~/Documents/Projects/Project-A in VS Code, and add a bookmark to Ëś/Documents/Projects/Project-A/some-file.json, the same file will not show that bookmarks if you instead open ~/Documents/Projects (parent folder), because to VS Code sessions, ~/Documents/Projects/Project-A and ~/Documents/Projects are two different locations.

Are you in some of these scenarios?

Hope this helps

mikeerickson commented 3 years ago

Hello

Thanks for chiming in. My end goal is to track down why I keep losing my bookmarks. It is surely not a show stopper keeping me from writing my code — just really puzzled why it happens (and seeming rather frequently)

Yes, I am using Prettier, but I am not sure how this is causing Bookmarks to lose track of items?

Is this a configuration issue on my end; is there something I need to do to keep this from happening?

alefragnani commented 3 years ago

Hi @mikeerickson ,

Well, if you use Prettier, than I think it may be the reason, but it’s not your fault.

As I said, I still have to properly handle how formatters work (support the way formatters report file/content changes). Until then, you have to use a workaround I created for it in #118 .

You must add a new setting ”bookmarks.useWorkaroundForFormatters”: true, and that’s all

The downside, you lose the sticky behavior bookmarks have today. This means, the bookmarks won’t automatically update (move up/down) when you change the code. So, instead of glued to the line of code it will be glued to the line of file.

Let me know if it works for you

mikeerickson commented 3 years ago

Ok, I will give this a whirl and see how it goes. I guess the “cool sync” feature does do me much good since my bookmarks keep disappearing anyway 🤓