Enable manual worktree organization (#11504)
Release Notes: - Preserve order of worktrees in project ([#10883](https://github.com/zed-industries/zed/issues/10883)). - Enable drag-and-drop reordering for project worktrees Note: worktree order is not synced during collaboration but guests can reorder their own project panels.  --------- Co-authored-by: Kirill Bulatov <kirill@zed.dev>
This commit is contained in:
parent
1e5389a2be
commit
b9697fb487
8 changed files with 479 additions and 54 deletions
|
@ -210,7 +210,9 @@ impl ProjectPanel {
|
|||
this.update_visible_entries(None, cx);
|
||||
cx.notify();
|
||||
}
|
||||
project::Event::WorktreeUpdatedEntries(_, _) | project::Event::WorktreeAdded => {
|
||||
project::Event::WorktreeUpdatedEntries(_, _)
|
||||
| project::Event::WorktreeAdded
|
||||
| project::Event::WorktreeOrderChanged => {
|
||||
this.update_visible_entries(None, cx);
|
||||
cx.notify();
|
||||
}
|
||||
|
@ -1239,6 +1241,48 @@ impl ProjectPanel {
|
|||
destination: ProjectEntryId,
|
||||
destination_is_file: bool,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
if self
|
||||
.project
|
||||
.read(cx)
|
||||
.entry_is_worktree_root(entry_to_move, cx)
|
||||
{
|
||||
self.move_worktree_root(entry_to_move, destination, cx)
|
||||
} else {
|
||||
self.move_worktree_entry(entry_to_move, destination, destination_is_file, cx)
|
||||
}
|
||||
}
|
||||
|
||||
fn move_worktree_root(
|
||||
&mut self,
|
||||
entry_to_move: ProjectEntryId,
|
||||
destination: ProjectEntryId,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
self.project.update(cx, |project, cx| {
|
||||
let Some(worktree_to_move) = project.worktree_for_entry(entry_to_move, cx) else {
|
||||
return;
|
||||
};
|
||||
let Some(destination_worktree) = project.worktree_for_entry(destination, cx) else {
|
||||
return;
|
||||
};
|
||||
|
||||
let worktree_id = worktree_to_move.read(cx).id();
|
||||
let destination_id = destination_worktree.read(cx).id();
|
||||
|
||||
project
|
||||
.move_worktree(worktree_id, destination_id, cx)
|
||||
.log_err();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
fn move_worktree_entry(
|
||||
&mut self,
|
||||
entry_to_move: ProjectEntryId,
|
||||
destination: ProjectEntryId,
|
||||
destination_is_file: bool,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
let destination_worktree = self.project.update(cx, |project, cx| {
|
||||
let entry_path = project.path_for_entry(entry_to_move, cx)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue