Update remoteUriFrom to handle POSIX style path#324806
Open
thbeu wants to merge 1 commit into
Open
Conversation
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @alexr00Matched files:
|
Contributor
There was a problem hiding this comment.
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-specificfsPathForUripassed toURI.file. - Adds drive-letter path detection (
/^\/?[a-zA-Z]:\//) to strip an optional leading slash on Windows before constructing the file URI. - Uses
displayPathfor 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, '\\'); | ||
| } | ||
| } |
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #314033