diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 296f6ca11de7756dc4e958877ee3e67bafb6cb2e..2303ac00f49fac2d6edf7e0cf2aa0f26f39c789a 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -350,6 +350,7 @@ pub fn init(cx: &mut App) { cx.set_global(GlobalBlameRenderer(Arc::new(()))); + dbg!(); workspace::register_project_item::(cx); workspace::FollowableViewRegistry::register::(cx); workspace::register_serializable_item::(cx); diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 760dd05ed1382307e5cc3471731074df6d95d106..cc813b8c15b09876ac560c552ca19ad77650970b 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -102,7 +102,7 @@ impl State { max_width_item_index: None, edit_state: old.edit_state.clone(), unfolded_dir_ids: old.unfolded_dir_ids.clone(), - selection: old.selection, + selection: dbg!(old.selection), expanded_dir_ids: old.expanded_dir_ids.clone(), } } @@ -398,6 +398,7 @@ pub fn init(cx: &mut App) { if let Some(first_marked) = panel.marked_entries.first() { let first_marked = *first_marked; panel.marked_entries.clear(); + dbg!(); panel.state.selection = Some(first_marked); } panel.rename(action, window, cx); @@ -729,8 +730,10 @@ impl ProjectPanel { focus_opened_item, allow_preview, } => { + dbg!(); if let Some(worktree) = project.read(cx).worktree_for_entry(entry_id, cx) && let Some(entry) = worktree.read(cx).entry_for_id(entry_id) { + dbg!(); let file_path = entry.path.clone(); let worktree_id = worktree.read(cx).id(); let entry_id = entry.id; @@ -767,12 +770,13 @@ impl ProjectPanel { }); if let Some(project_panel) = project_panel.upgrade() { + dbg!(); // Always select and mark the entry, regardless of whether it is opened or not. project_panel.update(cx, |project_panel, _| { let entry = SelectedEntry { worktree_id, entry_id }; project_panel.marked_entries.clear(); project_panel.marked_entries.push(entry); - project_panel.state.selection = Some(entry); + project_panel.state.selection = Some(dbg!(entry)); }); if !focus_opened_item { let focus_handle = project_panel.read(cx).focus_handle.clone(); @@ -957,6 +961,7 @@ impl ProjectPanel { return; }; + dbg!(); self.state.selection = Some(SelectedEntry { worktree_id, entry_id, @@ -1398,6 +1403,7 @@ impl ProjectPanel { worktree_id: *worktree_id, entry_id: entries[entry_ix].id, }; + dbg!(); self.state.selection = Some(selection); if window.modifiers().shift { self.marked_entries.push(selection); @@ -1575,6 +1581,7 @@ impl ProjectPanel { let edit_task; let edited_entry_id; if is_new_entry { + dbg!(); self.state.selection = Some(SelectedEntry { worktree_id, entry_id: NEW_ENTRY_ID, @@ -1629,6 +1636,7 @@ impl ProjectPanel { project_panel.update_in( cx, |project_panel, window, cx| { if let Some(selection) = &mut project_panel.state.selection && selection.entry_id == edited_entry_id { + dbg!(); selection.worktree_id = worktree_id; selection.entry_id = new_entry.id; project_panel.marked_entries.clear(); @@ -1689,6 +1697,7 @@ impl ProjectPanel { if let Some(previously_focused) = previous_edit_state.and_then(|edit_state| edit_state.previously_focused) { + dbg!(); self.state.selection = Some(previously_focused); self.autoscroll(cx); } @@ -1749,6 +1758,7 @@ impl ProjectPanel { .read(cx) .id(); + dbg!(); self.state.selection = Some(SelectedEntry { worktree_id, entry_id, @@ -2253,6 +2263,7 @@ impl ProjectPanel { worktree_id: *worktree_id, entry_id: entry.id, }; + dbg!(); self.state.selection = Some(selection); if window.modifiers().shift { self.marked_entries.push(selection); @@ -2292,6 +2303,7 @@ impl ProjectPanel { ); if let Some(selection) = selection { + dbg!(); self.state.selection = Some(selection); self.expand_entry(selection.worktree_id, selection.entry_id, cx); self.update_visible_entries( @@ -2331,6 +2343,7 @@ impl ProjectPanel { ); if let Some(selection) = selection { + dbg!(); self.state.selection = Some(selection); self.expand_entry(selection.worktree_id, selection.entry_id, cx); self.update_visible_entries( @@ -2369,6 +2382,7 @@ impl ProjectPanel { ); if let Some(selection) = selection { + dbg!(); self.state.selection = Some(selection); self.expand_entry(selection.worktree_id, selection.entry_id, cx); self.update_visible_entries( @@ -2404,6 +2418,7 @@ impl ProjectPanel { ); if let Some(selection) = selection { + dbg!(); self.state.selection = Some(selection); self.autoscroll(cx); cx.notify(); @@ -2432,6 +2447,7 @@ impl ProjectPanel { ); if let Some(selection) = selection { + dbg!(); self.state.selection = Some(selection); self.autoscroll(cx); cx.notify(); @@ -2461,6 +2477,7 @@ impl ProjectPanel { ); if let Some(selection) = selection { + dbg!(); self.state.selection = Some(selection); self.expand_entry(selection.worktree_id, selection.entry_id, cx); self.update_visible_entries( @@ -2479,6 +2496,7 @@ impl ProjectPanel { if let Some(parent) = entry.path.parent() { let worktree = worktree.read(cx); if let Some(parent_entry) = worktree.entry_for_path(parent) { + dbg!(); self.state.selection = Some(SelectedEntry { worktree_id: worktree.id(), entry_id: parent_entry.id, @@ -2504,6 +2522,7 @@ impl ProjectPanel { worktree_id: *worktree_id, entry_id: entry.id, }; + dbg!(); self.state.selection = Some(selection); if window.modifiers().shift { self.marked_entries.push(selection); @@ -2528,6 +2547,7 @@ impl ProjectPanel { worktree_id: *worktree_id, entry_id: entry.id, }; + dbg!(); self.state.selection = Some(selection); self.autoscroll(cx); cx.notify(); @@ -2679,16 +2699,19 @@ impl ProjectPanel { } // update selection if let Some(entry) = last_succeed { + dbg!(); project_panel .update_in(cx, |project_panel, window, cx| { + dbg!(); project_panel.state.selection = Some(SelectedEntry { worktree_id, - entry_id: entry.id, + entry_id: dbg!(entry.id), }); if item_count == 1 { // open entry if not dir, and only focus if rename is not pending - if !entry.is_dir() { + if !dbg!(entry.is_dir()) { + dbg!(); project_panel.open_entry( entry.id, disambiguation_range.is_none(), @@ -2699,6 +2722,7 @@ impl ProjectPanel { // if only one entry was pasted and it was disambiguated, open the rename editor if disambiguation_range.is_some() { + dbg!(); cx.defer_in(window, |this, window, cx| { this.rename_impl(disambiguation_range, window, cx); }); @@ -3192,6 +3216,7 @@ impl ProjectPanel { let old_ancestors = self.state.ancestors.clone(); let mut new_state = State::derive(&self.state); + dbg!(&new_state.selection); new_state.last_worktree_root_id = project .visible_worktrees(cx) .next_back() @@ -3419,15 +3444,17 @@ impl ProjectPanel { } } if let Some((worktree_id, entry_id)) = new_selected_entry { - new_state.selection = Some(SelectedEntry { + dbg!(); + new_state.selection = Some(dbg!(SelectedEntry { worktree_id, entry_id, - }); + })); } new_state }) .await; this.update_in(cx, |this, window, cx| { + dbg!(); this.state = new_state; let elapsed = now.elapsed(); if this.last_reported_update.elapsed() > Duration::from_secs(3600) { @@ -3639,6 +3666,7 @@ impl ProjectPanel { if let Some(entry_id) = last_succeed { project_panel .update_in(cx, |project_panel, window, cx| { + dbg!(); project_panel.state.selection = Some(SelectedEntry { worktree_id, entry_id, @@ -4593,6 +4621,7 @@ impl ProjectPanel { } } + dbg!(); project_panel.state.selection = Some(clicked_entry); if !project_panel.marked_entries.contains(&clicked_entry) { project_panel.marked_entries.push(clicked_entry); @@ -4602,6 +4631,7 @@ impl ProjectPanel { if event.click_count() > 1 { project_panel.split_entry(entry_id, false, None, cx); } else { + dbg!(); project_panel.state.selection = Some(selection); if let Some(position) = project_panel.marked_entries.iter().position(|e| *e == selection) { project_panel.marked_entries.remove(position); @@ -4988,6 +5018,9 @@ impl ProjectPanel { }; let is_marked = self.marked_entries.contains(&selection); let is_selected = self.state.selection == Some(selection); + if is_selected { + dbg!(&entry.path, &self.state.selection); + } let diagnostic_severity = self .diagnostics @@ -5452,6 +5485,7 @@ impl Render for ProjectPanel { return; }; + dbg!(); this.state.selection = Some(SelectedEntry { worktree_id, entry_id, diff --git a/crates/project_panel/src/project_panel_tests.rs b/crates/project_panel/src/project_panel_tests.rs index 27104558f2db2a360f420be3e345138c8c089a8c..b7a0bdc38878818595bc2273964faa3780f9caad 100644 --- a/crates/project_panel/src/project_panel_tests.rs +++ b/crates/project_panel/src/project_panel_tests.rs @@ -1445,6 +1445,10 @@ async fn test_cut_paste_between_different_worktrees(cx: &mut gpui::TestAppContex async fn test_copy_paste_between_different_worktrees(cx: &mut gpui::TestAppContext) { init_test(cx); + cx.update(|cx| { + register_project_item::(cx); + }); + let fs = FakeFs::new(cx.executor()); fs.insert_tree( "/root1", @@ -1489,9 +1493,16 @@ async fn test_copy_paste_between_different_worktrees(cx: &mut gpui::TestAppConte select_path(&panel, "root2/one.txt", cx); panel.update_in(cx, |panel, window, cx| { panel.select_next(&Default::default(), window, cx); + dbg!(); + }); + cx.executor().run_until_parked(); + dbg!(visible_entries_as_strings(&panel, 0..50, cx)); + panel.update_in(cx, |panel, window, cx| { panel.paste(&Default::default(), window, cx); + dbg!(); }); cx.executor().run_until_parked(); + dbg!(); assert_eq!( visible_entries_as_strings(&panel, 0..50, cx), &[ @@ -3103,6 +3114,7 @@ async fn test_rename_with_hide_root(cx: &mut gpui::TestAppContext) { let project = panel.project.read(cx); let worktree = project.visible_worktrees(cx).next().unwrap(); let root_entry = worktree.read(cx).root_entry().unwrap(); + dbg!(); panel.state.selection = Some(SelectedEntry { worktree_id: worktree.read(cx).id(), entry_id: root_entry.id, @@ -6683,7 +6695,7 @@ fn select_path(panel: &Entity, path: &str, cx: &mut VisualTestCont panel.update_in(cx, |panel, window, cx| { for worktree in panel.project.read(cx).worktrees(cx).collect::>() { let worktree = worktree.read(cx); - if let Ok(relative_path) = path.strip_prefix(worktree.root_name()) { + if let Ok(relative_path) = path.strip_prefix(dbg!(worktree.root_name())) { let entry_id = worktree.entry_for_path(relative_path).unwrap().id; panel.update_visible_entries( Some((worktree.id(), entry_id)), @@ -6692,6 +6704,7 @@ fn select_path(panel: &Entity, path: &str, cx: &mut VisualTestCont window, cx, ); + dbg!(path); return; } } @@ -6714,6 +6727,7 @@ fn select_path_with_mark(panel: &Entity, path: &str, cx: &mut Visu if !panel.marked_entries.contains(&entry) { panel.marked_entries.push(entry); } + dbg!(); panel.state.selection = Some(entry); return; } diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 4b19cc8c0ae06a8713f7fa67e35f3314db2510c1..530c950cdb07ee131309e1cb220fac4cf7f2ef7e 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -624,12 +624,14 @@ impl ProjectItemRegistry { let project_path = project_path.clone(); let is_file = project .read(cx) - .entry_for_path(&project_path, cx) + .entry_for_path(dbg!(&project_path), cx) .is_some_and(|entry| entry.is_file()); let entry_abs_path = project.read(cx).absolute_path(&project_path, cx); + dbg!(&entry_abs_path); let is_local = project.read(cx).is_local(); let project_item = ::try_open(project, &project_path, cx)?; + dbg!(); let project = project.clone(); Some(window.spawn(cx, async move |cx| { match project_item.await.with_context(|| { @@ -693,6 +695,7 @@ impl ProjectItemRegistry { window: &mut Window, cx: &mut App, ) -> Task, WorkspaceItemBuilder)>> { + dbg!(self.build_project_item_for_path_fns.len()); let Some(open_project_item) = self .build_project_item_for_path_fns .iter()