More Relative Paths In documentPath

#13 · closed · 1 comments

View on GitHub ↗

chm-tm

I'd like to share my bookmarks with my team by including it in my repository. However, our solutions are nested deeply inside the repository and most source files are outside the solution's directory. Bookmark Manager seems to currently serialize bookmarks of such paths as absolute paths which renders the `.bookmarks.json` unusable across the local machine. I tried to place the `.bookmarks.json` at repo top level. But this only works for git repos, and we use a different repo. Pretending a git repo by placing an empty `.git` folder in the root of the repo helps placing the `.bookmarks.json` top level, but still maintains absolute paths outside the solution directory. By the way, this will also be an issue if there are solutions at different places within the repo, since relative paths seem to be interpreted relative to the current solution. I suggest to always save the paths relative to the bookmarks file. This is what Visual Studio users are used to when it comes to links outside solutions/projects. Think twice whether relative paths should be used in the global bookmarks file as well. If you don't want to support relative paths outside the bookmarks file directory, please consider to support us placing the bookmarks file at an arbitrary level above the solution's directory, not just at the top of a git repo. This, in effect, will make the Bookmark Manager agnostic to any version control system.

Comments

madskristensen

Thanks for the detailed suggestion. This has been fixed by making shared Workspace bookmark files portable. What changed: - A `.bookmarks.json` file in the solution/repository root now saves `documentPath` values relative to the `.bookmarks.json` file itself. - This means a solution can be nested below the repository root, and bookmarks can point to files outside the solution directory without being written as machine-specific absolute paths. - Newly written Workspace bookmark files include `"documentPathRoot": "bookmarksFile"` so Bookmark Studio knows to resolve relative paths from the bookmark file location. - Existing bookmark files without that property continue to resolve paths relative to the solution directory, so existing files remain backward compatible. - Personal bookmark files in `.vs/.bookmarks.json` keep the old solution-relative behavior because they are user-specific and usually gitignored. - Global bookmarks still keep absolute paths. To use this for team sharing: 1. Put `.bookmarks.json` at the shared root you want paths to be relative from, typically the repository root. 2. Commit that `.bookmarks.json` file. 3. Open the solution and save/update bookmarks. New Workspace entries will be written relative to the `.bookmarks.json` file. If you already have a shared bookmark file and want the new behavior, let Bookmark Studio rewrite it after the update, or add `"documentPathRoot": "bookmarksFile"` at the root of the JSON file and ensure the `documentPath` values are relative to the `.bookmarks.json` location.