Skip to content

Commit

Permalink
Transfer breakpoints on project_panel file rename (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony-Eid authored Nov 10, 2024
1 parent 68ee3c7 commit b69d031
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/project/src/dap_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ impl DapStore {
self.active_debug_line.take();
}

pub fn on_file_rename(&mut self, old_project_path: ProjectPath, new_project_path: ProjectPath) {
if let Some(breakpoints) = self.breakpoints.remove(&old_project_path) {
self.breakpoints.insert(new_project_path, breakpoints);
}
}

pub fn breakpoints(&self) -> &BTreeMap<ProjectPath, HashSet<Breakpoint>> {
&self.breakpoints
}
Expand Down
16 changes: 16 additions & 0 deletions crates/project_panel/src/project_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,22 @@ impl ProjectPanel {
}
Ok(CreatedEntry::Included(new_entry)) => {
project_panel.update(&mut cx, |project_panel, cx| {
project_panel.project.update(cx, |project, cx| {
let old_path = ProjectPath {
worktree_id,
path: entry.path,
};

let new_path = ProjectPath {
worktree_id,
path: new_entry.path.clone()
};

project.dap_store().update(cx, |dap_store, _| {
dap_store.on_file_rename(old_path, new_path);
});
});

if let Some(selection) = &mut project_panel.selection {
if selection.entry_id == edited_entry_id {
selection.worktree_id = worktree_id;
Expand Down

0 comments on commit b69d031

Please sign in to comment.