Path Handling in VSCode

Did some exploring of how vscode resolves filepaths depending on the vpkg.vscode.ref.workspace (Private) configuration.

Observations:

  • file path resolution works as expected except when inside a vpkg.vscode.concepts.multi-root-workspace (Private)
    • inside a multi root workspace, absolute paths are resolved via the root of the workspace folder you current opened file happens to be in
    • if your current opened file is outside of any listed workspace folders, the root is resolved as the first workspace folder

This might sound a little confusing written out so some examples below.

File Layout

- root/ 
  - home.md
  - note.md
  - a/
      - home.md
      - note.md
  - b/
      - home.md
      - note.md
  - c/
      - home.md
      - note.md

Workspace Settings

{
	"folders": [
		{
			"path": "c"
		},
		{
			"path": "b"
		},
		{
			"path": "a"
		}
	],
	"settings": {}
}

Aliases

  • AP: absolute path
  • RP: relative path

Resolving paths from outside a workspace folder

  • testing from root/home.md
    • AP: [](/note.md): root/c/note.md <-- the / resolves to root/c because it is the first workspace folder from our worspace settings
    • RP: : root/note.md

Resolving paths from inside a workspace folder

  • testing from a/home.md
    • AP: [](/note.md): root/a/note.md
    • RP: [](note.md): root/a/note.md

Lookup


Tags

  1. mw