mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-23 00:50:35 +01:00
51a3a0e971
## Summary Follow-up of #64149, Zed currently has three handcrafted, identical `is_absolute()` functions, living in `crates/path/src/path.rs` and `crates/util/src/paths.rs`. They read as follows: https://github.com/zed-industries/zed/blob/93d745668805029476e6d7fbb19652116fed51de/crates/path/src/path.rs#L409-L420 In fact, these handcrafted methods behave like `Path::has_root()` rather than `Path::is_absolute()`. The difference between the two is that `Path::has_root()` only checks whether a path has a root, whereas `Path::is_absolute()` checks whether the path is truly absolute. On Unix, which has a single root, `has_root()` and `is_absolute()` coincide. Windows, however, is multi-rooted (`C:\` and `D:\` are different roots), so a rooted path such as `\temp\path` is not absolute: depending on the working directory, it may resolve to `C:\temp\path` or `D:\temp\path`, which are different paths. This misleading naming can lead to misuse of the API. This PR does three things: 1. Deduplicates the methods, keeping only `is_absolute()` in the `PathStyle` body. 2. Reimplements `PathStyle::has_root()` and `PathStyle::is_absolute()` based on the standard library’s implementations; the former replaces the old `is_absolute()`. 3. Updates some callers of the old `is_absolute()` (now `has_root()`, per step 2) to the new `is_absolute()`, based on each call site’s semantics and the actual behavior of the methods. Steps 1 and 2 are pure refactors; the only functional change is in step 3. I believe this fixes some edge cases — or at least surfaces things that need fixing — though I am not entirely certain that every replacement is correct. ## Testing No new tests are introduced. The refactored parts pass the existing tests in the affected crates. ## 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). - [ ] Tests cover the new or changed behavior. Release Notes: - N/A