Skip to content

fix: combine URI flags to prevent Electron argument filtering on Windows - #308150

Merged
Dmitriy Vasyura (dmitrivMS) merged 7 commits into
microsoft:mainfrom
maruthang:fix/issue-209072-folder-uri-windows
May 28, 2026
Merged

Dmitriy Vasyura (dmitrivMS) merged 7 commits into
microsoft:mainfrom
maruthang:fix/issue-209072-folder-uri-windows

Conversation

@maruthang

@maruthang Maruthan G (maruthang) commented Apr 7, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #209072

Summary

  • On Windows, Electron/Chromium's security layer filters out standalone command-line arguments that contain :// (treated as URLs). This causes --folder-uri and --file-uri to fail silently when the URI value is not the last argument.
  • Before spawning the Electron process in cli.ts, combine --folder-uri and --file-uri flags with their values using = syntax (e.g., --folder-uri=vscode-remote://...), so Chromium treats them as -- prefixed flags rather than standalone URL arguments.
  • This approach follows the suggestion from Robo (@deepak1556) in the issue comments to encode/transform the URI argument.

Test plan

  • On Windows, run code --folder-uri vscode-remote://ssh-remote+host@workspace --new-window — should open the remote workspace
  • On Windows, run code --folder-uri vscode-remote://ssh-remote+host@workspace --wait --new-window — should open and wait
  • On Windows, run code --file-uri vscode-remote://ssh-remote+host@/path/file.txt --new-window — should open the remote file
  • Verify --folder-uri still works as the last argument (existing behavior preserved)
  • Verify non-URI arguments are unaffected

On Windows, Electron/Chromium's security layer filters out standalone
command-line arguments that look like URLs (containing "://"). This
causes --folder-uri and --file-uri to fail silently when the URI value
is not the last argument.

Combine --folder-uri and --file-uri with their values using "=" syntax
before spawning the Electron process, so Chromium treats them as flags
rather than standalone URL arguments.

Fixes microsoft#209072
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Benjamin Pasero (@bpasero)

Matched files:

  • src/vs/code/node/cli.ts

Resolve conflict in src/vs/code/node/cli.ts. Extract combineUriFlags into src/vs/code/node/cliArgs.ts, shorten the comment, drop the Set in favor of a direct compare, and add unit tests.
Copilot AI review requested due to automatic review settings May 27, 2026 18:43
@dmitrivMS

Copy link
Copy Markdown
Collaborator

Did some cleanup, added tests.

@dmitrivMS

Copy link
Copy Markdown
Collaborator

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a Windows-specific VS Code CLI issue where Electron/Chromium filters standalone URL-like argv tokens (containing ://), causing --folder-uri / --file-uri invocations to fail depending on argument ordering. The fix rewrites these options into --flag=value form before spawning the Electron process so the URI is no longer a standalone argv entry.

Changes:

  • Add combineUriFlags(args) helper to join --folder-uri <value> / --file-uri <value> into --flag=value.
  • Apply the rewrite on Windows in src/vs/code/node/cli.ts right before spawning process.execPath.
  • Add unit tests for the argument rewrite helper.
Show a summary per file
File Description
src/vs/code/test/node/cliArgs.test.ts Adds unit tests covering --folder-uri/--file-uri rewriting behavior.
src/vs/code/node/cliArgs.ts Introduces combineUriFlags helper that joins URI flags with their values.
src/vs/code/node/cli.ts Uses combineUriFlags on Windows when spawning the Electron process to avoid Chromium filtering.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Comment thread src/vs/code/node/cliArgs.ts Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) enabled auto-merge (squash) May 27, 2026 23:55
@dmitrivMS Dmitriy Vasyura (dmitrivMS) added the workbench-cli VS Code Command line issues label May 27, 2026
@dmitrivMS
Dmitriy Vasyura (dmitrivMS) merged commit 3cb23da into microsoft:main May 28, 2026
25 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.123.0 milestone May 28, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Jul 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

workbench-cli VS Code Command line issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI on Windows: --folder-uri option only works as the last argument and when the --wait option is not present

5 participants