fix(windows): context menu "Open Warp in new tab" navigates to home dir (#9844)#9849
Open
KuaaMU wants to merge 1 commit intowarpdotdev:masterfrom
Open
fix(windows): context menu "Open Warp in new tab" navigates to home dir (#9844)#9849KuaaMU wants to merge 1 commit intowarpdotdev:masterfrom
KuaaMU wants to merge 1 commit intowarpdotdev:masterfrom
Conversation
…nstead of selected directory (warpdotdev#9844) The Windows Explorer context menu passes raw filesystem paths via `%1`/`%V` without URL-encoding them into the `warp://` URI query string. While the `url` crate handles bare backslashes and drive-letter colons correctly in most cases, the resulting `PathBuf` can still fail the `is_dir()` gate in `path_if_directory()` — for example when the OS needs a canonicalized form (symlinks, trailing separators, `\?\` prefix, etc.). When that happens the initial directory is silently dropped and the new tab falls back to `~`. Three changes: 1. `parse_tab_path` now trims trailing whitespace from the decoded path, catching an edge-case where `%1`/`%V` expansion appends invisible chars. 2. `path_if_directory` now falls back to `std::fs::canonicalize()` when `is_dir()` returns false, resolving symlinks, `.` / `..` segments, and other minor path normalization issues before giving up. 3. `on_open_urls` now has a Windows-only fallback: if `Url::parse()` fails on a bare `C:\...` path, it converts it to a `file:///` URL before retrying. This is a defense-in-depth measure for any code path that receives a raw Windows path instead of a properly-formatted URI. Closes warpdotdev#9844 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have the users @KuaaMU on file. In order for us to review and merge your code, each contributor must visit https://cla.warp.dev to read and agree to our CLA. Once you have done so, please comment |
Contributor
|
I ran into an unexpected error while working on this. You can view the conversation on Warp. Powered by Oz |
Author
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
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.
Summary
parse_tab_pathtrims trailing whitespace from the decoded path, catching an edge-case where%1/%Vexpansion appends invisible characterspath_if_directoryfalls back tostd::fs::canonicalize()whenis_dir()returns false, resolving symlinks,./..segments, and other minor path normalization issues before giving upon_open_urlshas a Windows-only fallback: ifUrl::parse()fails on a bareC:\...path, it converts to afile:///URL before retryingRoot cause
The Windows Explorer context menu passes raw filesystem paths via
%1/%Vwithout URL-encoding them into thewarp://URI query string. While theurlcrate handles bare backslashes and drive-letter colons correctly in most cases, the resultingPathBufcan still fail theis_dir()gate inpath_if_directory()— for example when the OS needs a canonicalized form (symlinks, trailing separators,\?\prefix, etc.). When that happens the initial directory is silently dropped and the new tab falls back to~.Verified by running actual Rust tests:
The URL parsing itself works fine — the issue is downstream in
path_if_directorywhereis_dir()can fail for paths that need canonicalization.Test plan
Closes #9844
Related: #6665 (Linux counterpart), #6143 (duplicate instances)
🤖 Generated with Claude Code