From 1995bd89a6ddd038cf15191612bf68877418bea5 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 2 Nov 2021 12:29:03 -0700 Subject: [PATCH] Deserialize buffer's diagnostics Co-Authored-By: Nathan Sobo --- crates/language/src/lib.rs | 8 +++++++- crates/project/src/worktree.rs | 2 +- script/sqlx | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/language/src/lib.rs b/crates/language/src/lib.rs index 306f08f3b8..dad8af83df 100644 --- a/crates/language/src/lib.rs +++ b/crates/language/src/lib.rs @@ -256,6 +256,7 @@ impl Buffer { replica_id: ReplicaId, message: proto::Buffer, file: Option>, + cx: &mut ModelContext, ) -> Result { 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.diagnostics = diagnostics; + self.diagnostics_update_count += 1; cx.notify(); } diff --git a/crates/project/src/worktree.rs b/crates/project/src/worktree.rs index 54f76a0d70..1862a342aa 100644 --- a/crates/project/src/worktree.rs +++ b/crates/project/src/worktree.rs @@ -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) }); diff --git a/script/sqlx b/script/sqlx index 590aad67eb..3d3ea00cc4 100755 --- a/script/sqlx +++ b/script/sqlx @@ -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)"