vscode-favorites icon indicating copy to clipboard operation
vscode-favorites copied to clipboard

relative to $(workspaceRoot)

Open Luka234 opened this issue 5 years ago • 5 comments

Favorites are stored with absolute paths. I wish it is possible to add favorite relative to workspaceRoot. In that case moving/renaming project and/or working on the same project on different computers (with different paths) would work.

Solution would be to use paths relative to vscode variable ${workspaceRoot}

Luka234 avatar May 02 '19 16:05 Luka234

I have the same need, when I sync a project with others and the workspace path is different all favorites are not working, inside the json i noticed there are two fields that remain null even if i edit manually: workspaceRoot and workspacePath

{
    "type": "File",
    "name": "c:\\Wamp\\www\\testsite\\routes\\web.php",
    "parent_id": null,
    "fsPath": "c:\\Wamp\\www\\testsite\\routes\\web.php",
    "workspaceRoot": null,
    "workspacePath": null,
    "id": "SswrZzXBEHy92d5q"
}

However, as you can see here ${workspaceRoot} is deprecated

In my case the .code-workspace file is inside the www folder, I tried a lot of possibilities setting paths relatives to ${workspaceFolder} but none of them worked

Ares9323 avatar May 11 '19 00:05 Ares9323

I was just looking to do the same. After taking a look into the current plugin code to see how it sets up its paths, I managed to make it work for me:

  • "name": "path/to/folder/or/file/relative/to/workspace/root/without/leading/or/ending/slash"
  • "fsPath": null
  • "workspaceRoot": null
  • "workspacePath": null

AcidGreg avatar Sep 11 '19 15:09 AcidGreg

@AcidGreg I tried this, not working though. Here are my settings settings.json

 "favorites.storageRegistry": [
    "/Users/username/favorites.json",
  ],

favorites.json

  {
    "type": "File",
    "name": "/Users/username/Documents/notes.md",
    "parent_id": null,
    "fsPath": null,
    "workspaceRoot": null,
    "workspacePath": null,
    "id": "5EM2LpqXfIiBybvm"
  }

mifas avatar Dec 19 '19 01:12 mifas

@mifas

    "name": "/Users/username/Documents/notes.md",

That path does not seem to be relative to the workspace. ;-) I only tried it with a relative path, as I wanted the whole thing to be portable.

AcidGreg avatar Dec 19 '19 13:12 AcidGreg

bummer, @AcidGreg idea seemed promising, but when i populate the name property with relative path and fsPath with null and then hit the "Refresh List" button, it repopulates fsPath and the error message when clicking a file still appears as if it's still going after absolute path... maybe this behavior changed since another release? FYI the current release i'm on looks like v2.4.5 from the VS Marketplace (which doesn't coincide with latest v2.3.0 in this repo's releases).

Beej126 avatar Jan 15 '20 17:01 Beej126