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:
co-authored by
Cole Miller
parent
301e976465
commit
495a7b0a84
@@ -915,7 +915,7 @@ impl WorkspaceDb {
|
||||
relative_worktree_path == String::default()
|
||||
);
|
||||
|
||||
let Some(relative_path) = RelPath::new(&relative_worktree_path).log_err() else {
|
||||
let Some(relative_path) = RelPath::unix(&relative_worktree_path).log_err() else {
|
||||
continue;
|
||||
};
|
||||
if worktree_id != u64::MAX && relative_worktree_path != String::default() {
|
||||
@@ -1001,7 +1001,7 @@ impl WorkspaceDb {
|
||||
for toolchain in toolchains {
|
||||
let query = sql!(INSERT OR REPLACE INTO user_toolchains(remote_connection_id, workspace_id, worktree_id, relative_worktree_path, language_name, name, path, raw_json) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8));
|
||||
let (workspace_id, worktree_id, relative_worktree_path) = match scope {
|
||||
ToolchainScope::Subproject(worktree_id, ref path) => (Some(workspace.id), Some(worktree_id), Some(path.as_str().to_owned())),
|
||||
ToolchainScope::Subproject(worktree_id, ref path) => (Some(workspace.id), Some(worktree_id), Some(path.as_unix_str().to_owned())),
|
||||
ToolchainScope::Project => (Some(workspace.id), None, None),
|
||||
ToolchainScope::Global => (None, None, None),
|
||||
};
|
||||
@@ -1661,7 +1661,7 @@ impl WorkspaceDb {
|
||||
workspace_id,
|
||||
language_name.as_ref().to_string(),
|
||||
worktree_id.to_usize(),
|
||||
relative_worktree_path.as_str().to_string(),
|
||||
relative_worktree_path.as_unix_str().to_string(),
|
||||
))?;
|
||||
|
||||
Ok(toolchain
|
||||
@@ -1743,7 +1743,7 @@ impl WorkspaceDb {
|
||||
insert((
|
||||
workspace_id,
|
||||
worktree_id.to_usize(),
|
||||
relative_worktree_path.as_str(),
|
||||
relative_worktree_path.as_unix_str(),
|
||||
toolchain.language_name.as_ref(),
|
||||
toolchain.name.as_ref(),
|
||||
toolchain.path.as_ref(),
|
||||
|
||||
@@ -2631,11 +2631,9 @@ impl Workspace {
|
||||
.strip_prefix(worktree_abs_path.as_ref())
|
||||
.ok()
|
||||
.and_then(|relative_path| {
|
||||
let relative_path = RelPath::from_std_path(
|
||||
relative_path,
|
||||
PathStyle::local(),
|
||||
)
|
||||
.log_err()?;
|
||||
let relative_path =
|
||||
RelPath::new(relative_path, PathStyle::local())
|
||||
.log_err()?;
|
||||
worktree.entry_for_path(&relative_path)
|
||||
})
|
||||
}
|
||||
@@ -10766,7 +10764,7 @@ mod tests {
|
||||
.flat_map(|item| {
|
||||
item.project_paths(cx)
|
||||
.into_iter()
|
||||
.map(|path| path.path.as_str().to_string())
|
||||
.map(|path| path.path.display(PathStyle::local()).into_owned())
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user