From f8295ffaca890db5cc177bfbb00ad3e4db46024d Mon Sep 17 00:00:00 2001 From: Hitesh Rohira <63107308+HiteshRohira@users.noreply.github.com> Date: Wed, 22 Apr 2026 03:54:49 +0530 Subject: [PATCH] Fix blank git diff view on Windows when working in a subfolder (#52234) ## Context Fixes a Windows path handling bug in `crates/util/src/paths.rs` when computing a relative path via `strip_prefix`. (Closes #51758 ) Previously, Windows prefix matching only handled drive-letter case-insensitivity. It could still fail when the parent and child paths referred to the same location but used different separator styles (`\` vs `/`) or different casing in later path segments. That caused valid Windows paths to return `None` instead of a relative path, which caused the diff to break. This change normalizes Windows paths for prefix comparison by lowercasing any ASCII characters and converting backslashes to forward slashes before checking the prefix. Tests were added for mixed-case and mixed-separator Windows paths to cover the bug and prevent further regressions. ## How to Review 1. Check the `strip_prefix` Windows branch to confirm the new normalization logic only affects prefix comparison and still rejects partial-segment matches. 2. Check the added tests for mixed separator and mixed casing cases on Windows paths. ## 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 is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - Fix blank git diff view on Windows when working in a subfolder --------- Co-authored-by: John Tur --- crates/project/src/git_store.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rs index d35a13e7df3e55df662ab09270b5ec5a5203c2a8..0d4051be7e52de206e1a719a25c1a804b756ff40 100644 --- a/crates/project/src/git_store.rs +++ b/crates/project/src/git_store.rs @@ -4024,10 +4024,12 @@ impl RepositorySnapshot { } fn repo_path_to_abs_path(&self, repo_path: &RepoPath) -> PathBuf { - self.path_style - .join(&self.work_directory_abs_path, repo_path.as_std_path()) - .unwrap() - .into() + let repo_path = repo_path.display(self.path_style); + PathBuf::from( + self.path_style + .join(&self.work_directory_abs_path, repo_path.as_ref()) + .unwrap(), + ) } #[inline]