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

@ -278,7 +278,7 @@ impl ProjectPanel {
.project
.read(cx)
.worktree_for_id(edit_state.worktree_id, cx)?;
let entry = worktree.read(cx).entry_for_id(edit_state.entry_id)?;
let entry = worktree.read(cx).entry_for_id(edit_state.entry_id)?.clone();
let filename = self.filename_editor.read(cx).text(cx);
if edit_state.new_file {
@ -306,9 +306,11 @@ impl ProjectPanel {
} else {
filename.into()
};
let rename = worktree.update(cx, |worktree, cx| {
worktree.as_local().unwrap().rename(old_path, new_path, cx)
});
let rename = self.project.update(cx, |project, cx| {
project.rename_entry(entry.id, new_path, cx)
})?;
Some(cx.spawn(|this, mut cx| async move {
let new_entry = rename.await?;
this.update(&mut cx, |this, cx| {