Skip to content

Update remoteUriFrom to handle POSIX style path#324806

Open
thbeu wants to merge 1 commit into
microsoft:mainfrom
thbeu:patch-1
Open

Update remoteUriFrom to handle POSIX style path#324806
thbeu wants to merge 1 commit into
microsoft:mainfrom
thbeu:patch-1

Conversation

@thbeu

@thbeu thbeu commented Jul 7, 2026

Copy link
Copy Markdown

Resolves #314033

Copilot AI review requested due to automatic review settings July 7, 2026 17:59
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

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

@alexr00

Matched files:

  • src/vs/workbench/services/dialogs/browser/simpleFileDialog.ts

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 modifies SimpleFileDialog.remoteUriFrom to better handle POSIX-style paths on Windows (issue #314033, e.g. typing c:/Users/... in the CTRL+O quick-open dialog). It separates the user-facing display path from the filesystem path handed to URI.file, and, on Windows, strips an optional leading slash and normalizes separators for drive-letter paths so the URI resolves correctly.

Changes:

  • Introduces a displayPath (preserving the user's forward slashes) distinct from a Windows-specific fsPathForUri passed to URI.file.
  • Adds drive-letter path detection (/^\/?[a-zA-Z]:\//) to strip an optional leading slash on Windows before constructing the file URI.
  • Uses displayPath for the scoped-authority and non-file-scheme URI construction paths.

import { URI } from '../../../../base/common/uri.js';
import { isWindows, OperatingSystem } from '../../../../base/common/platform.js';
import { ISaveDialogOptions, IOpenDialogOptions, IFileDialogService } from '../../../../platform/dialogs/common/dialogs.js';
import { ISaveDialogOptiremoteUriFromons, IOpenDialogOptions, IFileDialogService } from '../../../../platform/dialogs/common/dialogs.js';
Comment on lines +261 to +275
// Keep a display-friendly version of the path (preserve forward slashes the user typed)
let displayPath = path;
if (!displayPath.startsWith('\\\\')) {
displayPath = displayPath.replace(/\\/g, '/');
}

// Prepare a filesystem path to hand to URI.file on Windows when needed.
// Do NOT mutate displayPath so the UI keeps showing exactly what the user typed.
let fsPathForUri = displayPath;
if (this.scheme === Schemas.file && isWindows) {
if (/^\/?[a-zA-Z]:\//.test(displayPath)) {
// Remove optional leading slash and convert forward slashes -> backslashes for fs path
fsPathForUri = displayPath.replace(/^\//, '').replace(/\//g, '\\');
}
}
@thbeu

thbeu commented Jul 7, 2026

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CTRL+O should accept POSIX style path

3 participants