Files
zed/crates/worktree/src
Xin Zhao 9521840152 path: Reimplement PathStyle::join based on the standard library's implementation (#65966)
## Summary

Final follow-up of #64149, this PR reimplements `PathStyle::join()` on
top of `std::path::PathBuf::push`, via a new `PathStyle`-aware
`PathBufExt::styled_push` helper. The old `join_path()` and
`join_path_preserving_components()` are removed, and their call sites
are migrated as follows:

- `join` -> `join`
- `join_path` -> `join` + `normalize_lexically`
- `join_path_preserving_components` -> `join`, plus
`normalize_separators` only where the joined path is displayed to the
user

I'm confident that the new `join()` mirrors std's behavior. The main
thing to be aware of is that the old `join` rejected a rooted right-hand
side and returned `None`, while the new one accepts it and handles it:
the left-hand side is replaced entirely, except for a root-only operand
such as `\b` on Windows, which keeps the left side's prefix (`C:\a` +
`\b` = `C:\b`).

Because the old `join` rejected rooted right-hand sides, all migrated
call sites were audited for `has_root`: the right operand either cannot
be rooted by construction, or the call site already guards rooted inputs
with `has_root`, or an explicit guard was added here.

One edge case was noticed but left unchanged: a drive-relative operand
such as `C:foo.rs` is now replaced instead of concatenated (mirroring
std). This case was equally unhandled before, so it is left as-is here;
adding another check beyond the existing `has_root` guard would not be
self-explanatory either. #65911 (git worktree names containing path
components) is likewise pre-existing and tracked separately.

## Testing

New tests are added for the new `join` method, adapted from the std lib.
The tests of the affected caller crates have been run to prevent
regressions, but this is not a guarantee.

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [x] Tests cover the new or changed behavior.

Release Notes:

- N/A
2026-10-28 15:21:52 +00:00
..
…