Move buffer diff storage from BufferStore
to GitStore
(#26795)
Release Notes: - N/A --------- Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com> Co-authored-by: max <max@zed.dev>
This commit is contained in:
parent
3d1ae68f83
commit
011f823f33
13 changed files with 1395 additions and 1279 deletions
|
@ -665,6 +665,7 @@ impl Hover {
|
|||
enum EntitySubscription {
|
||||
Project(PendingEntitySubscription<Project>),
|
||||
BufferStore(PendingEntitySubscription<BufferStore>),
|
||||
GitStore(PendingEntitySubscription<GitStore>),
|
||||
WorktreeStore(PendingEntitySubscription<WorktreeStore>),
|
||||
LspStore(PendingEntitySubscription<LspStore>),
|
||||
SettingsObserver(PendingEntitySubscription<SettingsObserver>),
|
||||
|
@ -863,7 +864,6 @@ impl Project {
|
|||
buffer_store.clone(),
|
||||
environment.clone(),
|
||||
fs.clone(),
|
||||
client.clone().into(),
|
||||
cx,
|
||||
)
|
||||
});
|
||||
|
@ -992,7 +992,6 @@ impl Project {
|
|||
buffer_store.clone(),
|
||||
environment.clone(),
|
||||
ssh_proto.clone(),
|
||||
ProjectId(SSH_PROJECT_ID),
|
||||
cx,
|
||||
)
|
||||
});
|
||||
|
@ -1109,6 +1108,7 @@ impl Project {
|
|||
let subscriptions = [
|
||||
EntitySubscription::Project(client.subscribe_to_entity::<Self>(remote_id)?),
|
||||
EntitySubscription::BufferStore(client.subscribe_to_entity::<BufferStore>(remote_id)?),
|
||||
EntitySubscription::GitStore(client.subscribe_to_entity::<GitStore>(remote_id)?),
|
||||
EntitySubscription::WorktreeStore(
|
||||
client.subscribe_to_entity::<WorktreeStore>(remote_id)?,
|
||||
),
|
||||
|
@ -1137,7 +1137,7 @@ impl Project {
|
|||
|
||||
async fn from_join_project_response(
|
||||
response: TypedEnvelope<proto::JoinProjectResponse>,
|
||||
subscriptions: [EntitySubscription; 5],
|
||||
subscriptions: [EntitySubscription; 6],
|
||||
client: Arc<Client>,
|
||||
run_tasks: bool,
|
||||
user_store: Entity<UserStore>,
|
||||
|
@ -1254,7 +1254,7 @@ impl Project {
|
|||
remote_id,
|
||||
replica_id,
|
||||
},
|
||||
git_store,
|
||||
git_store: git_store.clone(),
|
||||
buffers_needing_diff: Default::default(),
|
||||
git_diff_debouncer: DebouncedDelay::new(),
|
||||
terminals: Terminals {
|
||||
|
@ -1284,6 +1284,9 @@ impl Project {
|
|||
EntitySubscription::WorktreeStore(subscription) => {
|
||||
subscription.set_entity(&worktree_store, &mut cx)
|
||||
}
|
||||
EntitySubscription::GitStore(subscription) => {
|
||||
subscription.set_entity(&git_store, &mut cx)
|
||||
}
|
||||
EntitySubscription::SettingsObserver(subscription) => {
|
||||
subscription.set_entity(&settings_observer, &mut cx)
|
||||
}
|
||||
|
@ -1874,6 +1877,9 @@ impl Project {
|
|||
self.settings_observer.update(cx, |settings_observer, cx| {
|
||||
settings_observer.shared(project_id, self.client.clone().into(), cx)
|
||||
});
|
||||
self.git_store.update(cx, |git_store, cx| {
|
||||
git_store.shared(project_id, self.client.clone().into(), cx)
|
||||
});
|
||||
|
||||
self.client_state = ProjectClientState::Shared {
|
||||
remote_id: project_id,
|
||||
|
@ -1955,6 +1961,9 @@ impl Project {
|
|||
self.settings_observer.update(cx, |settings_observer, cx| {
|
||||
settings_observer.unshared(cx);
|
||||
});
|
||||
self.git_store.update(cx, |git_store, cx| {
|
||||
git_store.unshared(cx);
|
||||
});
|
||||
|
||||
self.client
|
||||
.send(proto::UnshareProject {
|
||||
|
@ -2180,10 +2189,8 @@ impl Project {
|
|||
if self.is_disconnected(cx) {
|
||||
return Task::ready(Err(anyhow!(ErrorCode::Disconnected)));
|
||||
}
|
||||
|
||||
self.buffer_store.update(cx, |buffer_store, cx| {
|
||||
buffer_store.open_unstaged_diff(buffer, cx)
|
||||
})
|
||||
self.git_store
|
||||
.update(cx, |git_store, cx| git_store.open_unstaged_diff(buffer, cx))
|
||||
}
|
||||
|
||||
pub fn open_uncommitted_diff(
|
||||
|
@ -2194,9 +2201,8 @@ impl Project {
|
|||
if self.is_disconnected(cx) {
|
||||
return Task::ready(Err(anyhow!(ErrorCode::Disconnected)));
|
||||
}
|
||||
|
||||
self.buffer_store.update(cx, |buffer_store, cx| {
|
||||
buffer_store.open_uncommitted_diff(buffer, cx)
|
||||
self.git_store.update(cx, |git_store, cx| {
|
||||
git_store.open_uncommitted_diff(buffer, cx)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -2755,8 +2761,8 @@ impl Project {
|
|||
if buffers.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(this.buffer_store.update(cx, |buffer_store, cx| {
|
||||
buffer_store.recalculate_buffer_diffs(buffers, cx)
|
||||
Some(this.git_store.update(cx, |git_store, cx| {
|
||||
git_store.recalculate_buffer_diffs(buffers, cx)
|
||||
}))
|
||||
}
|
||||
})
|
||||
|
@ -4008,6 +4014,9 @@ impl Project {
|
|||
buffer.update(cx, |buffer, cx| buffer.remove_peer(replica_id, cx));
|
||||
}
|
||||
});
|
||||
this.git_store.update(cx, |git_store, _| {
|
||||
git_store.forget_shared_diffs_for(&peer_id);
|
||||
});
|
||||
|
||||
cx.emit(Event::CollaboratorLeft(peer_id));
|
||||
Ok(())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue