vscode-pull-request-github icon indicating copy to clipboard operation
vscode-pull-request-github copied to clipboard

Fix file URIs using wrong workspace folder in multi-root workspaces

Open Copilot opened this issue 2 months ago • 0 comments

In multi-root workspaces, temporary file URIs for PR diffs used the first workspace folder path instead of the correct one matching the repository.

Example:

Workspace with roots A and B, viewing PR from repo B:
- Expected: vscode-userdata:/.../temp/B/file.png
- Actual:   vscode-userdata:/.../temp/A/file.png  ❌

Changes

  • src/common/uri.ts: Pass repository.rootUri to TemporaryState.write() in asTempStorageURI()
  • src/common/temporaryState.ts:
    • Add optional repositoryUri parameter to writeState() and write()
    • Match workspace folder by comparing URIs instead of always using first folder
    • Fall back to first folder if no match (preserves single-root behavior)
Original prompt

This section details on the original issue you should resolve

<issue_title>Wrong file URIs with multiple roots</issue_title> <issue_description>Type: Bug

File URIs are wrong when you have a multiple root workspace.

For example: I have a workspace with roots A an B and a PR for root B

  • A (master)
  • B (PR branch)

When I open a file from the PR branch the vscode-userdata URI for the non-local file contains the path with root A.

URIs of both files in diff view:

  • file:///home/username/B/file.png
  • vscode-userdata:/home/username/.config/Code/User/globalStorage/github.vscode-pull-request-github/temp/A/filename.png

I'd expect the vscode-userdata file to have B in the root path instead of A:

  • vscode-userdata:/home/username/.config/Code/User/globalStorage/github.vscode-pull-request-github/temp/B/filename.png

I've only checked with image files, but I assume this could happen with other files as well.

Extension version: 0.94.0 VS Code version: Code 1.92.2 (fee1edb8d6d72a0ddff41e5f71a671c23ed924b9, 2024-08-14T17:29:30.058Z) OS version: Linux x64 5.14.0-1048-oem Modes:

Comments on the Issue (you are @copilot in this section)

  • Fixes microsoft/vscode-pull-request-github#6156

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot avatar Dec 10 '25 11:12 Copilot