Clean up RelPath API (#38912)

Consolidate constructors and accessors.

Release Notes:

- N/A

---------

Co-authored-by: Cole Miller <cole@zed.dev>
This commit is contained in:
Max Brunsfeld
2025-09-25 14:42:32 -07:00
committed by GitHub
co-authored by Cole Miller
parent 301e976465
commit 495a7b0a84
70 changed files with 483 additions and 408 deletions
+4 -4
View File
@@ -1062,10 +1062,10 @@ impl DebugPanel {
directory_in_worktree: dir,
..
} => {
let relative_path = if dir.ends_with(RelPath::new(".vscode").unwrap()) {
dir.join(RelPath::new("launch.json").unwrap())
let relative_path = if dir.ends_with(RelPath::unix(".vscode").unwrap()) {
dir.join(RelPath::unix("launch.json").unwrap())
} else {
dir.join(RelPath::new("debug.json").unwrap())
dir.join(RelPath::unix("debug.json").unwrap())
};
ProjectPath {
worktree_id: id,
@@ -1136,7 +1136,7 @@ impl DebugPanel {
}
path.pop();
path.push(paths::local_debug_file_relative_path());
path.push(paths::local_debug_file_relative_path().as_std_path());
let path = path.as_path();
if !fs.is_file(path).await {
+4 -4
View File
@@ -1037,10 +1037,10 @@ impl DebugDelegate {
match path.components().next_back() {
Some(".zed") => {
path.push(RelPath::new("debug.json").unwrap());
path.push(RelPath::unix("debug.json").unwrap());
}
Some(".vscode") => {
path.push(RelPath::new("launch.json").unwrap());
path.push(RelPath::unix("launch.json").unwrap());
}
_ => {}
}
@@ -1133,7 +1133,7 @@ impl DebugDelegate {
id: _,
directory_in_worktree: dir,
id_base: _,
} => dir.ends_with(RelPath::new(".zed").unwrap()),
} => dir.ends_with(RelPath::unix(".zed").unwrap()),
_ => false,
});
@@ -1154,7 +1154,7 @@ impl DebugDelegate {
id_base: _,
} => {
!(hide_vscode
&& dir.ends_with(RelPath::new(".vscode").unwrap()))
&& dir.ends_with(RelPath::unix(".vscode").unwrap()))
}
_ => true,
})
@@ -682,10 +682,11 @@ impl Render for BreakpointList {
breakpoints.into_iter().filter_map(move |breakpoint| {
debug_assert_eq!(&path, &breakpoint.path);
let file_name = breakpoint.path.file_name()?;
let breakpoint_path = RelPath::new(&breakpoint.path, path_style).ok();
let dir = relative_worktree_path
.clone()
.or_else(|| RelPath::from_std_path(&breakpoint.path, path_style).ok())?
.as_deref()
.or(breakpoint_path.as_deref())?
.parent()
.map(|parent| SharedString::from(parent.display(path_style).to_string()));
let name = file_name