Skip to content

editor: Fix file URL navigation in hover popover on Windows#59248

Open
MZZW wants to merge 2 commits into
zed-industries:mainfrom
MZZW:main
Open

editor: Fix file URL navigation in hover popover on Windows#59248
MZZW wants to merge 2 commits into
zed-industries:mainfrom
MZZW:main

Conversation

@MZZW

@MZZW MZZW commented Jun 13, 2026

Copy link
Copy Markdown

Use Url::to_file_path() instead of PathBuf::from(uri.path()) in
open_markdown_url. On Windows, url::Url::path() returns paths with a
leading slash (e.g., /D:/path/to/file.rs), which PathBuf::from()
cannot resolve correctly. This caused LSP hover links (file:// URIs from
language servers) to fail navigation on Windows.

Url::to_file_path() handles the platform-specific path conversion
properly - it strips the leading slash on Windows and returns the
correct D:\path\to\file format.

Objective

Fix LSP hover popover file links failing to navigate when clicking on
Windows. The root cause is that PathBuf::from(uri.path()) does not
handle the leading / in the URL path on Windows.

Solution

Use url::Url::to_file_path() instead of PathBuf::from(uri.path()).
to_file_path() is the standard, cross-platform way to convert a
file:// URL to a native PathBuf — it correctly strips the leading
slash on Windows and produces proper D:\... paths.

Testing

  • Tested manually by inspecting the parsed path values on a Windows
    machine.
  • The fix is mechanical (one-liner replacement) and only affects the
    Windows code path. Non-Windows platforms remain unaffected.
  • Added unit test test_file_url_to_path_conversion_on_windows in
    hover_popover.rs that verifies Url::to_file_path() produces the
    correct path.
  • Existing tests in mention.rs (test_parse_file_uris_use_native_separators_on_windows)
    cover the same underlying path conversion logic and pass.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • The content adheres to Zed's UI standards
  • Tests cover the new/changed behavior (unit test in hover_popover.rs)
  • Performance impact has been considered and is acceptable

Release Notes:

  • Fixed LSP hover link navigation failing on Windows due to incorrect file path resolution

MZZW added 2 commits June 13, 2026 16:12
Use `Url::to_file_path()` instead of `PathBuf::from(uri.path())` in
`open_markdown_url`. On Windows, `url::Url::path()` returns paths with
a leading slash (e.g., `/D:/path/to/file.rs`), which
`PathBuf::from()` cannot resolve correctly. This caused LSP hover
links (file:// URIs from language servers) to fail navigation on
Windows.

`Url::to_file_path()` handles the platform-specific path conversion
properly - it strips the leading slash on Windows and returns the
correct D:\path\to\file format.

Release Notes:

- Fixed LSP hover link navigation failing on Windows due to incorrect
file path resolution
Add a test verifying that `Url::to_file_path()` correctly handles
Windows-style file:// URLs, which is the conversion used in
`open_markdown_url`.

Release Notes:

- N/A
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 13, 2026
@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant