Remove worktree_id from buffer-related RPC messages

This commit is contained in:
Max Brunsfeld 2022-01-21 16:23:39 -08:00
parent 03dc1e5aea
commit 34e42c0c5f
3 changed files with 11 additions and 31 deletions

View File

@ -1504,7 +1504,6 @@ impl Project {
.and_then(|shared_buffers| shared_buffers.get(&envelope.payload.buffer_id).cloned())
.ok_or_else(|| anyhow!("unknown buffer id {}", envelope.payload.buffer_id))?;
let receipt = envelope.receipt();
let worktree_id = envelope.payload.worktree_id;
let buffer_id = envelope.payload.buffer_id;
let save = cx.spawn(|_, mut cx| async move {
buffer.update(&mut cx, |buffer, cx| buffer.save(cx)).await
@ -1519,7 +1518,6 @@ impl Project {
receipt,
proto::BufferSaved {
project_id,
worktree_id,
buffer_id,
version: (&version).into(),
mtime: Some(mtime.into()),

View File

@ -38,8 +38,7 @@ use std::{
},
time::{Duration, SystemTime},
};
use sum_tree::{Bias, TreeMap};
use sum_tree::{Edit, SeekTarget, SumTree};
use sum_tree::{Bias, Edit, SeekTarget, SumTree, TreeMap};
use util::ResultExt;
lazy_static! {
@ -398,22 +397,17 @@ impl Worktree {
operation: Operation,
cx: &mut ModelContext<Self>,
) {
if let Some((project_id, worktree_id, rpc)) = match self {
if let Some((project_id, rpc)) = match self {
Worktree::Local(worktree) => worktree
.share
.as_ref()
.map(|share| (share.project_id, worktree.id(), worktree.client.clone())),
Worktree::Remote(worktree) => Some((
worktree.project_id,
worktree.snapshot.id(),
worktree.client.clone(),
)),
.map(|share| (share.project_id, worktree.client.clone())),
Worktree::Remote(worktree) => Some((worktree.project_id, worktree.client.clone())),
} {
cx.spawn(|worktree, mut cx| async move {
if let Err(error) = rpc
.request(proto::UpdateBuffer {
project_id,
worktree_id: worktree_id.0 as u64,
buffer_id,
operations: vec![language::proto::serialize_operation(&operation)],
})
@ -1408,7 +1402,6 @@ impl language::File for File {
version: clock::Global,
cx: &mut MutableAppContext,
) -> Task<Result<(clock::Global, SystemTime)>> {
let worktree_id = self.worktree.read(cx).id().to_proto();
self.worktree.update(cx, |worktree, cx| match worktree {
Worktree::Local(worktree) => {
let rpc = worktree.client.clone();
@ -1419,7 +1412,6 @@ impl language::File for File {
if let Some(project_id) = project_id {
rpc.send(proto::BufferSaved {
project_id,
worktree_id,
buffer_id,
version: (&version).into(),
mtime: Some(entry.mtime.into()),
@ -1436,7 +1428,6 @@ impl language::File for File {
let response = rpc
.request(proto::SaveBuffer {
project_id,
worktree_id,
buffer_id,
})
.await?;
@ -1467,14 +1458,12 @@ impl language::File for File {
cx: &mut MutableAppContext,
) -> Option<Task<Result<()>>> {
let worktree = self.worktree.read(cx);
let worktree_id = worktree.id().to_proto();
let worktree = worktree.as_remote()?;
let rpc = worktree.client.clone();
let project_id = worktree.project_id;
Some(cx.foreground().spawn(async move {
rpc.request(proto::FormatBuffer {
project_id,
worktree_id,
buffer_id,
})
.await?;
@ -1492,14 +1481,12 @@ impl language::File for File {
self.worktree.update(cx, |worktree, cx| {
if let Worktree::Remote(worktree) = worktree {
let project_id = worktree.project_id;
let worktree_id = worktree.id().to_proto();
let rpc = worktree.client.clone();
cx.background()
.spawn(async move {
if let Err(error) = rpc
.send(proto::CloseBuffer {
project_id,
worktree_id,
buffer_id,
})
.await

View File

@ -144,35 +144,30 @@ message OpenBufferResponse {
message CloseBuffer {
uint64 project_id = 1;
uint64 worktree_id = 2;
uint64 buffer_id = 3;
uint64 buffer_id = 2;
}
message UpdateBuffer {
uint64 project_id = 1;
uint64 worktree_id = 2;
uint64 buffer_id = 3;
uint64 buffer_id = 2;
repeated Operation operations = 4;
}
message SaveBuffer {
uint64 project_id = 1;
uint64 worktree_id = 2;
uint64 buffer_id = 3;
uint64 buffer_id = 2;
}
message BufferSaved {
uint64 project_id = 1;
uint64 worktree_id = 2;
uint64 buffer_id = 3;
repeated VectorClockEntry version = 4;
Timestamp mtime = 5;
uint64 buffer_id = 2;
repeated VectorClockEntry version = 3;
Timestamp mtime = 4;
}
message FormatBuffer {
uint64 project_id = 1;
uint64 worktree_id = 2;
uint64 buffer_id = 3;
uint64 buffer_id = 2;
}
message UpdateDiagnosticSummary {