Fix accidental usages of local worktree id instead of remote id

This commit is contained in:
Max Brunsfeld 2021-12-20 18:06:58 -08:00
parent 55910c0d79
commit 5d8d7de68d

View file

@ -766,18 +766,25 @@ impl Worktree {
operation: Operation, operation: Operation,
cx: &mut ModelContext<Self>, cx: &mut ModelContext<Self>,
) { ) {
if let Some((project_id, rpc)) = match self { if let Some((project_id, worktree_id, rpc)) = match self {
Worktree::Local(worktree) => worktree Worktree::Local(worktree) => worktree.share.as_ref().map(|share| {
.share (
.as_ref() share.project_id,
.map(|share| (share.project_id, worktree.client.clone())), worktree.id() as u64,
Worktree::Remote(worktree) => Some((worktree.project_id, worktree.client.clone())), worktree.client.clone(),
)
}),
Worktree::Remote(worktree) => Some((
worktree.project_id,
worktree.remote_id,
worktree.client.clone(),
)),
} { } {
cx.spawn(|worktree, mut cx| async move { cx.spawn(|worktree, mut cx| async move {
if let Err(error) = rpc if let Err(error) = rpc
.request(proto::UpdateBuffer { .request(proto::UpdateBuffer {
project_id, project_id,
worktree_id: worktree.id() as u64, worktree_id,
buffer_id, buffer_id,
operations: vec![language::proto::serialize_operation(&operation)], operations: vec![language::proto::serialize_operation(&operation)],
}) })
@ -1972,10 +1979,10 @@ impl language::File for File {
} }
fn buffer_removed(&self, buffer_id: u64, cx: &mut MutableAppContext) { fn buffer_removed(&self, buffer_id: u64, cx: &mut MutableAppContext) {
let worktree_id = self.worktree.id() as u64;
self.worktree.update(cx, |worktree, cx| { self.worktree.update(cx, |worktree, cx| {
if let Worktree::Remote(worktree) = worktree { if let Worktree::Remote(worktree) = worktree {
let project_id = worktree.project_id; let project_id = worktree.project_id;
let worktree_id = worktree.remote_id;
let rpc = worktree.client.clone(); let rpc = worktree.client.clone();
cx.background() cx.background()
.spawn(async move { .spawn(async move {