Start on adding support for editing via the assistant panel (#14795)
Note that this shouldn't have any visible user-facing behavior yet. The feature is incomplete but we wanna merge early to avoid a long-running branch. Release Notes: - N/A --------- Co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
parent
87457f9ae8
commit
4d177918c1
44 changed files with 1999 additions and 968 deletions
|
@ -8403,6 +8403,37 @@ impl Project {
|
|||
})
|
||||
}
|
||||
|
||||
/// Attempts to find a `ProjectPath` corresponding to the given full path.
|
||||
///
|
||||
/// This method iterates through all worktrees in the project, trying to match
|
||||
/// the given full path against each worktree's root name. If a match is found,
|
||||
/// it returns a `ProjectPath` containing the worktree ID and the relative path
|
||||
/// within that worktree.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `full_path` - A reference to a `Path` representing the full path to resolve.
|
||||
/// * `cx` - A reference to the `AppContext`.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// Returns `Some(ProjectPath)` if a matching worktree is found, otherwise `None`.
|
||||
pub fn project_path_for_full_path(
|
||||
&self,
|
||||
full_path: &Path,
|
||||
cx: &AppContext,
|
||||
) -> Option<ProjectPath> {
|
||||
self.worktrees.iter().find_map(|worktree| {
|
||||
let worktree = worktree.upgrade()?;
|
||||
let worktree_root_name = worktree.read(cx).root_name();
|
||||
let relative_path = full_path.strip_prefix(worktree_root_name).ok()?;
|
||||
Some(ProjectPath {
|
||||
worktree_id: worktree.read(cx).id(),
|
||||
path: relative_path.into(),
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_workspace_root(
|
||||
&self,
|
||||
project_path: &ProjectPath,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue