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

relative to $(workspaceRoot) #38

Open Luka234 opened 5 years ago

Luka234 commented 5 years ago

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}

Ares9323 commented 5 years ago

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

AcidGreg commented 5 years ago

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:

mifas commented 4 years ago

@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"
  }
AcidGreg commented 4 years ago

@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.

Beej126 commented 4 years ago

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).