zed/docs/src
Xin Zhao fa00dccc42
Fix project path handling when connecting from Unix to Windows remotes (#62038)
# Objective

Follow-up of #61374.

Zed now supports Windows as a remote target, but when connecting from a
Unix platform to Windows, some path handling still uses the native
client's path style (Unix) to construct paths, which causes weird path
displays in different areas.

One of them is the project path stored in the `settings.json` file,
which is related to the open path picker in the codebase:

5e1fd392f6/crates/open_path_prompt/src/open_path_prompt.rs (L668-L679)
For example, if I have a remote project at `D:\code\test_python` and
want to open it in remote development, I usually use path completions,
with `D:\code\` as the parent path and `test_python` as the selected
candidate. Zed directly joins them using `Path::join` on the Unix
platform, which results in `D:\code\/test_python`.

A second thing I found is the displayed name for the git repo. The
related source code is:

5e1fd392f6/crates/title_bar/src/title_bar.rs (L262-L268)
Also taking `D:\code\test_python` as an example: the passed-in
`common_dir_abs_path` is `D:\code\test_python\.git`, and
`repo_identity_path()` directly uses `Path::file_name()` and
`Path::parent()` from the standard library to handle this:

5e1fd392f6/crates/project/src/git_store.rs (L9956-L9965)
Ideally, this function should return `D:\code\test_python`. But due to
the platform mismatch, `D:\code\test_python\.git` is returned; after
further processing in the title bar, we get `D:\code\test_python\` as
the displayed name, while the expected display name is `test_python`.

In the past, only Unix-like systems could serve as remote servers, and
their path separator (`/`) is valid on Windows, so everything looked
fine. But Unix does not support `\` as a valid separator — that's the
root cause. We need to use `PathStyle`, which is designed for processing
paths across platforms, to deal with these cases.

## Solution

- Added new APIs `PathStyle::parent()` and `PathStyle::file_name()`,
which serve as replacements for `Path::parent()` and `Path::file_name()`
to process paths cross-platform.
- Adopted the new APIs in `repo_identity_path()`, and updated the
relevant call sites.
- For the open path picker, use `PathStyle::join_path()` instead of
`Path::join`.

## Testing

The added `PathStyle::parent()` and `PathStyle::file_name()` are covered
by detailed unit tests. These tests verify that the behavior matches the
corresponding methods in `Path`, just independent of the host platform.

For the path display issues, I built and tested manually; a comparison
is attached in the Showcase section.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

## Showcase

<details>
  <summary>Click to view showcase</summary>

| Content | Before | After |
|:--:|:--:|:--:|
|title bar|<img width="486" height="272" alt="title_bar_before"
src="https://github.com/user-attachments/assets/d14d0e37-a1b8-43ab-b51b-fe9dd1b977eb"
/> | <img width="406" height="274" alt="title_bar_after"
src="https://github.com/user-attachments/assets/fc9193f4-d42c-47a8-a254-4ed08c806a11"
/> |
|path storage| <img width="337" height="264" alt="project_path_before"
src="https://github.com/user-attachments/assets/3352add3-20df-43b9-8a20-10ee7d96e703"
/>| <img width="319" height="262" alt="project_path_after"
src="https://github.com/user-attachments/assets/fa3d7feb-f393-416a-868d-85eb0af5cfb8"
/>|
|open remote| <img width="554" height="135" alt="open_remote_before"
src="https://github.com/user-attachments/assets/62983eca-22ad-472f-8333-8561cfc17357"
/>|<img width="562" height="176" alt="open_remote_after"
src="https://github.com/user-attachments/assets/22528a6b-0e73-4a12-a825-673ba57a63da"
/> |
</details>


## Other things to note
This PR also did a little refactoring: it moved the `PathStyle`-related
tests from the `util` crate to the `path` crate, and updated the
documentation to reflect that Windows can serve as a remote platform.

The recent project picker also suffers from the same cross-platform bug,
but it is not fixed here, because a clean fix requires dealing with
database storage, unlike the direct API changes made here. I will
address it in a follow-up PR.

This PR looks very large, but most of the changes are the test migration
and the new API implementation. I hope the unit tests and comments can
offload some of the burden for reviewers.

---

Release Notes:

- Fixed project paths being built incorrectly when connecting from Unix
machines to Windows remote servers.
2026-08-19 12:16:37 +00:00
..
account Document Claude Opus 5 hosted model pricing (#62450) 2026-08-10 19:32:44 +00:00
ai agent: OpenCode model updates (+6 Go, +7/-1 Zen, removed Free) (#61199) 2026-08-19 11:07:38 +00:00
business Update Zed-hosted model documentation (#60771) 2026-07-10 23:24:52 +00:00
collaboration docs: Update actions format (#54869) 2026-05-07 06:55:11 +00:00
development Remove stale musl linker error workaround from Linux dev docs (#61444) 2026-07-22 10:04:12 +00:00
extensions docs: Split up extension publishing documentation (#62312) 2026-08-13 21:02:09 +00:00
languages docs: Add PHPantom language server configuration (#61387) 2026-07-22 13:46:00 +00:00
migrate JetBrains keymap: Add CamelHump subword navigation (#51540) 2026-08-14 12:31:48 +00:00
reference Fix the git_gutter_width setting (#62704) 2026-08-18 12:40:18 +00:00
all-actions.md docs: Apply documentation standards across all docs (#49177) 2026-02-17 20:58:17 -06:00
appearance.md docs: Add missing font fallback documentation (#55779) 2026-07-30 12:51:08 +00:00
authentication.md Fix typos and grammatical mistakes in docs (#59495) 2026-07-08 12:32:00 +00:00
command-palette.md Fix typos and grammatical mistakes in docs (#59495) 2026-07-08 12:32:00 +00:00
completions.md Remove Supermaven-related code from Zed (#50537) 2026-03-02 22:18:49 +00:00
configuring-languages.md Adjust language docs (#62551) 2026-08-13 10:22:47 +00:00
configuring-zed.md Restructure AI docs (#57614) 2026-06-04 15:55:21 +00:00
debugger.md Fix typos and grammatical mistakes in docs (#59495) 2026-07-08 12:32:00 +00:00
dev-containers.md dev_container: Support the classic Docker builder via a setting (#59288) 2026-06-15 07:04:03 +00:00
development.md Improve documentation for ETW profiling (#50426) 2026-02-28 23:03:49 -05:00
diagnostics.md Fix typos and grammatical mistakes in docs (#59495) 2026-07-08 12:32:00 +00:00
editing-code.md docs: SEO content improvements for AI section (#49128) 2026-02-13 13:05:57 -08:00
environment.md Fix typos and grammatical mistakes in docs (#59495) 2026-07-08 12:32:00 +00:00
extensions.md docs: Split up extension publishing documentation (#62312) 2026-08-13 21:02:09 +00:00
finding-navigating.md docs: Add new text finder (#60189) 2026-07-03 18:46:05 +00:00
getting-started.md Fixes for AI docs (#58969) 2026-06-11 15:15:55 +00:00
git.md Added Tracked , Staged options to stash (#62254) 2026-08-18 05:36:16 +00:00
globs.md Fix grammatical errors throughout the documentation (#58183) 2026-05-31 22:05:41 +00:00
helix.md docs: Apply documentation standards across all docs (#49177) 2026-02-17 20:58:17 -06:00
icon-themes.md docs: Update actions format (#54869) 2026-05-07 06:55:11 +00:00
installation.md Fix grammatical errors throughout the documentation (#58183) 2026-05-31 22:05:41 +00:00
key-bindings.md JetBrains keymap: Add CamelHump subword navigation (#51540) 2026-08-14 12:31:48 +00:00
languages.md Fix grammatical errors throughout the documentation (#58183) 2026-05-31 22:05:41 +00:00
linux.md Remove the 3rd party section (#61087) 2026-07-16 07:51:58 +00:00
macos.md install_cli: Show notification instead of failing CLI install (#59575) 2026-06-22 18:20:57 +00:00
modelines.md Add vim/emacs modeline support (#49267) 2026-03-25 03:15:51 +00:00
multibuffers.md Fix grammatical errors throughout the documentation (#58183) 2026-05-31 22:05:41 +00:00
outline-panel.md docs: Update actions format (#54869) 2026-05-07 06:55:11 +00:00
performance.md Fix typos and grammatical mistakes in docs (#59495) 2026-07-08 12:32:00 +00:00
project-panel.md Make file scanner less eager in non-git-tracked directory trees (#62583) 2026-08-13 17:07:06 +00:00
quick-start.md docs: Reorganize introduction (#41387) 2025-10-28 17:39:40 -03:00
remote-development.md Fix project path handling when connecting from Unix to Windows remotes (#62038) 2026-08-19 12:16:37 +00:00
repl.md docs: Add note about toolchain selection for Python REPL (#60549) 2026-07-30 03:19:59 +00:00
roles.md Document Billing Manager role (#58447) 2026-06-03 18:17:18 +00:00
running-testing.md docs: Apply documentation standards across all docs (#49177) 2026-02-17 20:58:17 -06:00
semantic-tokens.md docs: Update actions format (#54869) 2026-05-07 06:55:11 +00:00
snippets.md snippets: Strip path separators from language snippet file names (#61421) 2026-07-23 04:49:39 +00:00
soc2.md docs: Restructure nav and add Zed Business section (#51915) 2026-05-06 16:07:12 +00:00
SUMMARY.md docs: Split up extension publishing documentation (#62312) 2026-08-13 21:02:09 +00:00
tab-switcher.md docs: Apply documentation standards across all docs (#49177) 2026-02-17 20:58:17 -06:00
tasks.md git_ui: Pass the clicked ref to git graph custom commands (#58781) 2026-06-09 06:30:07 +00:00
telemetry.md docs: Fix stale panic struct reference in telemetry docs (#61145) 2026-07-21 06:01:42 +00:00
terminal.md terminal: Open links with Cmd/Ctrl-click when mouse mode is enabled (#60067) 2026-07-08 12:41:48 +00:00
themes.md docs: Update actions format (#54869) 2026-05-07 06:55:11 +00:00
toolchains.md docs: Apply documentation standards across all docs (#49177) 2026-02-17 20:58:17 -06:00
troubleshooting.md feedback: Add action for listing installed extensions (#48664) 2026-04-16 07:45:38 +00:00
uninstall.md docs: Update guide to remove user data on macOS when uninstalling Zed (#52631) 2026-03-31 05:35:04 +00:00
update.md docs: Update actions format (#54869) 2026-05-07 06:55:11 +00:00
vim.md Fix typos and grammatical mistakes in docs (#59495) 2026-07-08 12:32:00 +00:00
visual-customization.md docs: Fix mismatch of default dock position setting in project panel (#61971) 2026-07-31 07:38:17 +00:00
windows-and-projects.md Fixes for AI docs (#58969) 2026-06-11 15:15:55 +00:00
windows.md docs: Apply documentation standards across all docs (#49177) 2026-02-17 20:58:17 -06:00
worktree-trust.md Fix typos and grammatical mistakes in docs (#59495) 2026-07-08 12:32:00 +00:00