Deserialize buffer's diagnostics

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld 2021-11-02 12:29:03 -07:00
parent 2c57703ad6
commit 1995bd89a6
3 changed files with 9 additions and 3 deletions

View File

@ -256,6 +256,7 @@ impl Buffer {
replica_id: ReplicaId,
message: proto::Buffer,
file: Option<Box<dyn File>>,
cx: &mut ModelContext<Self>,
) -> Result<Self> {
let mut buffer =
buffer::Buffer::new(replica_id, message.id, History::new(message.content.into()));
@ -268,7 +269,11 @@ impl Buffer {
let set = proto::deserialize_selection_set(set);
buffer.add_raw_selection_set(set.id, set);
}
Ok(Self::build(buffer, file))
let mut this = Self::build(buffer, file);
if let Some(diagnostics) = message.diagnostics {
this.apply_diagnostic_update(proto::deserialize_diagnostics(diagnostics), cx);
}
Ok(this)
}
pub fn to_proto(&self) -> proto::Buffer {
@ -1351,6 +1356,7 @@ impl Buffer {
cx: &mut ModelContext<Self>,
) {
self.diagnostics = diagnostics;
self.diagnostics_update_count += 1;
cx.notify();
}

View File

@ -1391,7 +1391,7 @@ impl RemoteWorktree {
let remote_buffer = response.buffer.ok_or_else(|| anyhow!("empty buffer"))?;
let buffer_id = remote_buffer.id as usize;
let buffer = cx.add_model(|cx| {
Buffer::from_proto(replica_id, remote_buffer, Some(Box::new(file)))
Buffer::from_proto(replica_id, remote_buffer, Some(Box::new(file)), cx)
.unwrap()
.with_language(language, None, cx)
});

View File

@ -5,7 +5,7 @@ set -e
# Install sqlx-cli if needed
[[ "$(sqlx --version)" == "sqlx-cli 0.5.7" ]] || cargo install sqlx-cli --version 0.5.7
cd server
cd crates/server
# Export contents of .env.toml
eval "$(cargo run --bin dotenv)"