alefragnani / vscode-bookmarks

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

[FEATURE] - Allow multiple or sub-folder bookmark settings #527

Closed enoversum closed 2 years ago

enoversum commented 2 years ago

I’m mostly developing WordPress themes, based on a skeleton theme that I improve over the years. I can successfully go into its project and set bookmarks in files, and with bookmarks.saveBookmarksInProject set to true, they are being stored in its .vscode folder. My workflow is then for every site I build to create a new project, install WordPress into it and copy the base theme (with a new folder name) into my new project, so the theme folder is now a sub-folder of the new project.

Since your extension seems to expect me to have the bookmarks.json inside the root of my project (and not in the theme’s sub-folder), my bookmarks do not show up. Is there a way to make Bookmarks recognise my sub-folder bookmarks.json? Since the theme folder name changes for every WordPress project, I cannot even prepare a bookmarks.json file in the .vscode folder.

alefragnani commented 2 years ago

Hi @enoversum ,

It seems you should use what VS Code calls as Multi-root Workspaces. The extension supports it.

With that, you create a workspace (which is nothing more than a .code-workspace file) and define this workspace to save bookmarks in project, setting bookmarks.saveBookmarksInProject: true on workspace level. Then, you add each site/project as a new folder. When you toggle a bookmark, the bookmark will be saved on its own .vscode/bookmarks.json. When a new site/project is created, you simply add it to this Workspace and its bookmarks will be saved on its own .vscode/bookmarks.json file.

I suggest you to define the the same bookmarks.saveBookmarksInProject for each folder, and not only in workspace level, because if for any reason you need to open that site/project alone, you will reuse the same bookmarks.

There is one catch, that I discovered yesterday while testing #461 . It seems the multi-root workspace activation has changed in recent release, so the extension won't recognize a newly added folder automatically. So, when after you add a new folder to your workspace, simply reload VS Code and the extension will properly work. I still don't know if I'll have to update the extension or if VS Code itself will change/fix something, but if I have to change anything, I'll link the issue here, so you will be notified.

Hope this helps

enoversum commented 2 years ago

Hello @alefragnani, thanks for your detailed explanation. I think I understand multi-root workspaces, but it doesn't seem like just the thing I want to do. Here is how I usually work:

  1. I have my base theme sitting at a safe place on my disk, which I saved as a project, via the Project Manager plugin. So projects are stored in a projects.json, but I believe they are not really new workspaces in the VS Code sense.
  2. I have an automated routine that downloads the latest WordPress, some plugins I am always using, grabs my theme directory and copies it into its themes folder and creates a new site on my local server from it. Thus, my theme folder with its .vscode folder and my bookmarks file is being copied over.
  3. I create a new project in VS Code that points to that place. From my understanding, it's not a separate workspace.
  4. Since the WordPress installation is one folder (with a sub-folder of my theme that contains your bookmarks file), and not a multi-root workspace, Bookmarks unfortunately does not find my bookmarks.

If I am not mistaken, since I don't have a multi-root workspace, having separate sub-folders with .vscode does nothing for Bookmarks, does it? And that would be my problem then 😊.

Thanks for taking care of me, I really appreciate it!

enoversum commented 2 years ago

@alefragnani Just a small follow-up question: Did I assess the situation right, and there is currently no way to have sub-folder based bookmarks, like described above?

enoversum commented 1 year ago

@alefragnani Hi there again, just chiming in to ask whether there is any support planned for sub-folder bookmarks instead of only root folder bookmarks? As explained, my bookmarks-equipped theme is in a subfolder of a VS Code project, and changes its name on every project, so I couldn't link it from a root-folder bookmarks file. As previously stated, multi-root projects are not what I need, as all files are in one folder.