kdcro101 / vscode-favorites

Add files and directories to workspace favorites. You can create groups (and subgroups) of favorite items with files and folders. Time saver for complex projects.
MIT License
49 stars 13 forks source link

Favorites not relative to workspace with multiple project folders #55

Open B1Dobbs opened 3 years ago

B1Dobbs commented 3 years ago

Describe the bug When using either the global .favorites.json or the multi-set feature for different projects / workspaces, the files for this extension are stored in first folder in the workspace rather than relative to the workspace.

To Reproduce Steps to reproduce the behavior:

  1. Open VSCode
  2. Add second folder to the workspace
  3. Add a favorite
  4. See that favorite .json file was added at the root of the first folder in the workspace.

Expected behavior .favorites.json should have been stored and referenced relative to the workspace file ending in 'code-workspace'.

Screenshots image Favorites Settings image Result

System info (please complete the following information):

Additional info Notice that .favorites.json is under the folder labeled 'classic'. If I were to remove that folder from the workspace, my .favorites.json stored there would be inaccessible and then any new ones would be stored in the new top folder.

My .code-workspace file is located two folders up from the 'classic' folder and that's where I expected the favorite config files to be stored. With the favorites json files stored in the top folder, it now shows up on source control for that project which is problematic.

GitMensch commented 2 years ago

That's actually the described way, changing this would break existing setups. I'd suggest to have, in your code-workspace:

"favorites.storageFilePath":"../../.favorites.json"

then - according to the docs - it should work (untested)

B1Dobbs commented 2 years ago

Hm, I don't think it's understood what I mentioned in the issue. My workspace is saved a couple folders up whereas the folder 'classic' is in the same folder as 'pro'. They are separate projects I work on in the same workspace.

So instead of favorites.json being stored relative to the workspace as it should be based on the note in settings, it is stored in the first project folder in my workspace. Why would the note say 'Storage file path relative to workspace' if it's really relative to the first folder in the workspace?

GitMensch commented 2 years ago

Readme has:

favorites.useWorkspace: number - default is 0 index of workspace to use as root when composing storage file path

So according to the docs it seems to be it always uses the first entry (zero based), while you want the "root" or one above, so use the appropriate one. A FR to have it relative to "real project root" with a value of -1 or similar sounds totally reasonable, but that would be @kdcro101's thing to adjust/implement.