Merge de4640f23f
into 0e575b2809
This commit is contained in:
commit
ee5542e6b0
1 changed files with 29 additions and 1 deletions
|
@ -448,6 +448,31 @@ impl GitStore {
|
|||
pub fn is_local(&self) -> bool {
|
||||
matches!(self.state, GitStoreState::Local { .. })
|
||||
}
|
||||
pub fn set_active_repo_for_path(&mut self, project_path: &ProjectPath, cx: &mut Context<Self>) {
|
||||
if let Some(worktree) = self
|
||||
.worktree_store
|
||||
.read(cx)
|
||||
.worktree_for_id(project_path.worktree_id, cx)
|
||||
{
|
||||
let abs_file_path = worktree
|
||||
.read(cx)
|
||||
.abs_path()
|
||||
.join(project_path.path.as_ref());
|
||||
|
||||
for (id, repo) in &self.repositories {
|
||||
let repo_path = repo.read(cx).work_directory_abs_path.clone();
|
||||
if abs_file_path.starts_with(&repo_path) {
|
||||
if self.active_repo_id != Some(*id) {
|
||||
self.active_repo_id = Some(*id);
|
||||
cx.emit(GitStoreEvent::ActiveRepositoryChanged(Some(*id)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
pub fn shared(&mut self, project_id: u64, client: AnyProtoClient, cx: &mut Context<Self>) {
|
||||
match &mut self.state {
|
||||
|
@ -1134,7 +1159,6 @@ impl GitStore {
|
|||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn on_repository_event(
|
||||
&mut self,
|
||||
repo: Entity<Repository>,
|
||||
|
@ -1292,6 +1316,10 @@ impl GitStore {
|
|||
diffs.remove(buffer_id);
|
||||
}
|
||||
}
|
||||
BufferStoreEvent::BufferOpened { project_path, .. } => {
|
||||
self.set_active_repo_for_path(project_path, cx);
|
||||
}
|
||||
|
||||
|
||||
_ => {}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue