project: Change Git repo automatically with change in file buffer (#36796)
### Summary * Auto-activates the active repository when opening a buffer. * Prepares branching for future support of a user choice (e.g., `auto_activate_repo_on_open` flag). ### Release Notes * **Improved**: Opening a buffer now automatically updates the active repository.
This commit is contained in:
@@ -4400,8 +4400,16 @@ impl Workspace {
|
||||
fn active_item_path_changed(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
cx.emit(Event::ActiveItemChanged);
|
||||
let active_entry = self.active_project_path(cx);
|
||||
self.project
|
||||
.update(cx, |project, cx| project.set_active_path(active_entry, cx));
|
||||
self.project.update(cx, |project, cx| {
|
||||
project.set_active_path(active_entry.clone(), cx)
|
||||
});
|
||||
|
||||
if let Some(project_path) = &active_entry {
|
||||
let git_store_entity = self.project.read(cx).git_store().clone();
|
||||
git_store_entity.update(cx, |git_store, cx| {
|
||||
git_store.set_active_repo_for_path(project_path, cx);
|
||||
});
|
||||
}
|
||||
|
||||
self.update_window_title(window, cx);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user