Fix git features not working when a Windows host collaborates with a unix guest (#43515)
We were using `std::path::Path::strip_prefix` to determine which repository an absolute path belongs to, which doesn't work when the paths are Windows-style but the code is running on unix. Replace it with a platform-agnostic implementation of `strip_prefix`. Release Notes: - Fixed git features not working when a Windows host collaborates with a unix guest
This commit is contained in:
@@ -1060,7 +1060,7 @@ impl FileFinderDelegate {
|
||||
(
|
||||
filename.to_string(),
|
||||
Vec::new(),
|
||||
prefix.display(path_style).to_string() + path_style.separator(),
|
||||
prefix.display(path_style).to_string() + path_style.primary_separator(),
|
||||
Vec::new(),
|
||||
)
|
||||
} else {
|
||||
@@ -1071,7 +1071,7 @@ impl FileFinderDelegate {
|
||||
.map_or(String::new(), |f| f.to_string_lossy().into_owned()),
|
||||
Vec::new(),
|
||||
entry_path.absolute.parent().map_or(String::new(), |path| {
|
||||
path.to_string_lossy().into_owned() + path_style.separator()
|
||||
path.to_string_lossy().into_owned() + path_style.primary_separator()
|
||||
}),
|
||||
Vec::new(),
|
||||
)
|
||||
|
||||
@@ -1598,7 +1598,7 @@ async fn test_history_match_positions(cx: &mut gpui::TestAppContext) {
|
||||
assert_eq!(file_label.highlight_indices(), &[0, 1, 2]);
|
||||
assert_eq!(
|
||||
path_label.text(),
|
||||
format!("test{}", PathStyle::local().separator())
|
||||
format!("test{}", PathStyle::local().primary_separator())
|
||||
);
|
||||
assert_eq!(path_label.highlight_indices(), &[] as &[usize]);
|
||||
});
|
||||
|
||||
@@ -559,7 +559,7 @@ impl PickerDelegate for OpenPathDelegate {
|
||||
parent_path,
|
||||
candidate.path.string,
|
||||
if candidate.is_dir {
|
||||
path_style.separator()
|
||||
path_style.primary_separator()
|
||||
} else {
|
||||
""
|
||||
}
|
||||
@@ -569,7 +569,7 @@ impl PickerDelegate for OpenPathDelegate {
|
||||
parent_path,
|
||||
candidate.path.string,
|
||||
if candidate.is_dir {
|
||||
path_style.separator()
|
||||
path_style.primary_separator()
|
||||
} else {
|
||||
""
|
||||
}
|
||||
@@ -826,7 +826,13 @@ impl PickerDelegate for OpenPathDelegate {
|
||||
}
|
||||
|
||||
fn placeholder_text(&self, _window: &mut Window, _cx: &mut App) -> Arc<str> {
|
||||
Arc::from(format!("[directory{}]filename.ext", self.path_style.separator()).as_str())
|
||||
Arc::from(
|
||||
format!(
|
||||
"[directory{}]filename.ext",
|
||||
self.path_style.primary_separator()
|
||||
)
|
||||
.as_str(),
|
||||
)
|
||||
}
|
||||
|
||||
fn separators_after_indices(&self) -> Vec<usize> {
|
||||
|
||||
Reference in New Issue
Block a user