Rebuild buffer store to be aware of remote/local distinction (#18303)
Release Notes: - N/A --------- Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
parent
da1ef13442
commit
c4e0f5e0ee
6 changed files with 1127 additions and 826 deletions
|
@ -1667,16 +1667,8 @@ impl Project {
|
|||
}
|
||||
|
||||
pub fn create_buffer(&mut self, cx: &mut ModelContext<Self>) -> Task<Result<Model<Buffer>>> {
|
||||
self.buffer_store.update(cx, |buffer_store, cx| {
|
||||
buffer_store.create_buffer(
|
||||
if self.is_via_collab() {
|
||||
Some((self.client.clone().into(), self.remote_id().unwrap()))
|
||||
} else {
|
||||
None
|
||||
},
|
||||
cx,
|
||||
)
|
||||
})
|
||||
self.buffer_store
|
||||
.update(cx, |buffer_store, cx| buffer_store.create_buffer(cx))
|
||||
}
|
||||
|
||||
pub fn create_local_buffer(
|
||||
|
@ -1685,7 +1677,7 @@ impl Project {
|
|||
language: Option<Arc<Language>>,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) -> Model<Buffer> {
|
||||
if self.is_via_collab() {
|
||||
if self.is_via_collab() || self.is_via_ssh() {
|
||||
panic!("called create_local_buffer on a remote project")
|
||||
}
|
||||
self.buffer_store.update(cx, |buffer_store, cx| {
|
||||
|
@ -3770,7 +3762,9 @@ impl Project {
|
|||
envelope: TypedEnvelope<proto::OpenNewBuffer>,
|
||||
mut cx: AsyncAppContext,
|
||||
) -> Result<proto::OpenBufferResponse> {
|
||||
let buffer = this.update(&mut cx, |this, cx| this.create_local_buffer("", None, cx))?;
|
||||
let buffer = this
|
||||
.update(&mut cx, |this, cx| this.create_buffer(cx))?
|
||||
.await?;
|
||||
let peer_id = envelope.original_sender_id()?;
|
||||
|
||||
Project::respond_to_open_buffer_request(this, buffer, peer_id, &mut cx)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue