Rename entries via the project to prepare for guest support

Co-Authored-By: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
Nathan Sobo 2022-05-04 09:11:59 -06:00 committed by Max Brunsfeld
parent 657ea264cc
commit 470d693d5e
3 changed files with 32 additions and 10 deletions

View file

@ -730,6 +730,26 @@ impl Project {
}
}
pub fn rename_entry(
&mut self,
entry_id: ProjectEntryId,
new_path: impl Into<Arc<Path>>,
cx: &mut ModelContext<Self>,
) -> Option<Task<Result<Entry>>> {
if self.is_local() {
let worktree = self.worktree_for_entry(entry_id, cx)?;
worktree.update(cx, |worktree, cx| {
worktree
.as_local_mut()
.unwrap()
.rename_entry(entry_id, new_path, cx)
})
} else {
todo!()
}
}
pub fn can_share(&self, cx: &AppContext) -> bool {
self.is_local() && self.visible_worktrees(cx).next().is_some()
}