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
+7 -11
View File
@@ -306,10 +306,10 @@ pub fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
return;
};
let path_style = worktree.read(cx).path_style();
let Ok(project_path) = RelPath::from_std_path(Path::new(&action.filename), path_style)
.map(|path| ProjectPath {
let Ok(project_path) =
RelPath::new(Path::new(&action.filename), path_style).map(|path| ProjectPath {
worktree_id: worktree.read(cx).id(),
path,
path: path.into_arc(),
})
else {
// TODO implement save_as with absolute path
@@ -372,14 +372,12 @@ pub fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
return;
};
let path_style = worktree.read(cx).path_style();
let Some(path) =
RelPath::from_std_path(Path::new(&action.filename), path_style).log_err()
else {
let Some(path) = RelPath::new(Path::new(&action.filename), path_style).log_err() else {
return;
};
let project_path = ProjectPath {
worktree_id: worktree.read(cx).id(),
path,
path: path.into_arc(),
};
let direction = if action.vertical {
@@ -472,14 +470,12 @@ pub fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
return;
};
let path_style = worktree.read(cx).path_style();
let Some(path) =
RelPath::from_std_path(Path::new(&action.filename), path_style).log_err()
else {
let Some(path) = RelPath::new(Path::new(&action.filename), path_style).log_err() else {
return;
};
let project_path = ProjectPath {
worktree_id: worktree.read(cx).id(),
path,
path: path.into_arc(),
};
let _ = workspace.update(cx, |workspace, cx| {