mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-18 18:08:07 +03:00
Store buffer's diagnostic sets in a smallvec
This commit is contained in:
parent
960a2bc589
commit
32c57bcd22
@ -76,6 +76,7 @@ serde_derive = { version = "1.0", features = ["deserialize_in_place"] }
|
|||||||
serde_json = { version = "1.0", features = ["preserve_order", "raw_value"] }
|
serde_json = { version = "1.0", features = ["preserve_order", "raw_value"] }
|
||||||
rand = { version = "0.8" }
|
rand = { version = "0.8" }
|
||||||
postage = { version = "0.5", features = ["futures-traits"] }
|
postage = { version = "0.5", features = ["futures-traits"] }
|
||||||
|
smallvec = { version = "1.6", features = ["union"] }
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
tree-sitter = { git = "https://github.com/tree-sitter/tree-sitter", rev = "c51896d32dcc11a38e41f36e3deb1a6a9c4f4b14" }
|
tree-sitter = { git = "https://github.com/tree-sitter/tree-sitter", rev = "c51896d32dcc11a38e41f36e3deb1a6a9c4f4b14" }
|
||||||
|
@ -18,4 +18,4 @@ settings = { path = "../settings" }
|
|||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
workspace = { path = "../workspace" }
|
workspace = { path = "../workspace" }
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
smallvec = { version = "1.6", features = ["union"] }
|
smallvec = { workspace = true }
|
||||||
|
@ -9,4 +9,4 @@ path = "src/clock.rs"
|
|||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
smallvec = { version = "1.6", features = ["union"] }
|
smallvec = { workspace = true }
|
||||||
|
@ -13,4 +13,4 @@ gpui = { path = "../gpui" }
|
|||||||
menu = { path = "../menu" }
|
menu = { path = "../menu" }
|
||||||
settings = { path = "../settings" }
|
settings = { path = "../settings" }
|
||||||
theme = { path = "../theme" }
|
theme = { path = "../theme" }
|
||||||
smallvec = "1.6"
|
smallvec = { workspace = true }
|
||||||
|
@ -10,7 +10,7 @@ doctest = false
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
smallvec = { version = "1.6", features = ["union"] }
|
smallvec = { workspace = true }
|
||||||
collections = { path = "../collections" }
|
collections = { path = "../collections" }
|
||||||
editor = { path = "../editor" }
|
editor = { path = "../editor" }
|
||||||
language = { path = "../language" }
|
language = { path = "../language" }
|
||||||
|
@ -58,7 +58,7 @@ postage = { workspace = true }
|
|||||||
rand = { version = "0.8.3", optional = true }
|
rand = { version = "0.8.3", optional = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
serde_derive = { workspace = true }
|
serde_derive = { workspace = true }
|
||||||
smallvec = { version = "1.6", features = ["union"] }
|
smallvec = { workspace = true }
|
||||||
smol = "1.2"
|
smol = "1.2"
|
||||||
tree-sitter-rust = { version = "*", optional = true }
|
tree-sitter-rust = { version = "*", optional = true }
|
||||||
tree-sitter-html = { version = "*", optional = true }
|
tree-sitter-html = { version = "*", optional = true }
|
||||||
|
@ -44,7 +44,7 @@ seahash = "4.1"
|
|||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
serde_derive = { workspace = true }
|
serde_derive = { workspace = true }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
smallvec = { version = "1.6", features = ["union"] }
|
smallvec = { workspace = true }
|
||||||
smol = "1.2"
|
smol = "1.2"
|
||||||
time = { version = "0.3", features = ["serde", "serde-well-known"] }
|
time = { version = "0.3", features = ["serde", "serde-well-known"] }
|
||||||
tiny-skia = "0.5"
|
tiny-skia = "0.5"
|
||||||
|
@ -50,7 +50,7 @@ serde = { workspace = true }
|
|||||||
serde_derive = { workspace = true }
|
serde_derive = { workspace = true }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
similar = "1.3"
|
similar = "1.3"
|
||||||
smallvec = { version = "1.6", features = ["union"] }
|
smallvec = { workspace = true }
|
||||||
smol = "1.2"
|
smol = "1.2"
|
||||||
tree-sitter = "0.20"
|
tree-sitter = "0.20"
|
||||||
tree-sitter-rust = { version = "*", optional = true }
|
tree-sitter-rust = { version = "*", optional = true }
|
||||||
|
@ -13,7 +13,6 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use clock::ReplicaId;
|
use clock::ReplicaId;
|
||||||
use collections::HashMap;
|
|
||||||
use fs::LineEnding;
|
use fs::LineEnding;
|
||||||
use futures::FutureExt as _;
|
use futures::FutureExt as _;
|
||||||
use gpui::{fonts::HighlightStyle, AppContext, Entity, ModelContext, Task};
|
use gpui::{fonts::HighlightStyle, AppContext, Entity, ModelContext, Task};
|
||||||
@ -21,6 +20,7 @@ use lsp::LanguageServerId;
|
|||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use similar::{ChangeTag, TextDiff};
|
use similar::{ChangeTag, TextDiff};
|
||||||
|
use smallvec::SmallVec;
|
||||||
use smol::future::yield_now;
|
use smol::future::yield_now;
|
||||||
use std::{
|
use std::{
|
||||||
any::Any,
|
any::Any,
|
||||||
@ -73,7 +73,7 @@ pub struct Buffer {
|
|||||||
syntax_map: Mutex<SyntaxMap>,
|
syntax_map: Mutex<SyntaxMap>,
|
||||||
parsing_in_background: bool,
|
parsing_in_background: bool,
|
||||||
parse_count: usize,
|
parse_count: usize,
|
||||||
diagnostics: HashMap<LanguageServerId, DiagnosticSet>,
|
diagnostics: SmallVec<[(LanguageServerId, DiagnosticSet); 2]>,
|
||||||
remote_selections: TreeMap<ReplicaId, SelectionSet>,
|
remote_selections: TreeMap<ReplicaId, SelectionSet>,
|
||||||
selections_update_count: usize,
|
selections_update_count: usize,
|
||||||
diagnostics_update_count: usize,
|
diagnostics_update_count: usize,
|
||||||
@ -90,7 +90,7 @@ pub struct BufferSnapshot {
|
|||||||
pub git_diff: git::diff::BufferDiff,
|
pub git_diff: git::diff::BufferDiff,
|
||||||
pub(crate) syntax: SyntaxSnapshot,
|
pub(crate) syntax: SyntaxSnapshot,
|
||||||
file: Option<Arc<dyn File>>,
|
file: Option<Arc<dyn File>>,
|
||||||
diagnostics: HashMap<LanguageServerId, DiagnosticSet>,
|
diagnostics: SmallVec<[(LanguageServerId, DiagnosticSet); 2]>,
|
||||||
diagnostics_update_count: usize,
|
diagnostics_update_count: usize,
|
||||||
file_update_count: usize,
|
file_update_count: usize,
|
||||||
git_diff_update_count: usize,
|
git_diff_update_count: usize,
|
||||||
@ -1652,7 +1652,10 @@ impl Buffer {
|
|||||||
cx: &mut ModelContext<Self>,
|
cx: &mut ModelContext<Self>,
|
||||||
) {
|
) {
|
||||||
if lamport_timestamp > self.diagnostics_timestamp {
|
if lamport_timestamp > self.diagnostics_timestamp {
|
||||||
self.diagnostics.insert(server_id, diagnostics);
|
match self.diagnostics.binary_search_by_key(&server_id, |e| e.0) {
|
||||||
|
Err(ix) => self.diagnostics.insert(ix, (server_id, diagnostics)),
|
||||||
|
Ok(ix) => self.diagnostics[ix].1 = diagnostics,
|
||||||
|
};
|
||||||
self.diagnostics_timestamp = lamport_timestamp;
|
self.diagnostics_timestamp = lamport_timestamp;
|
||||||
self.diagnostics_update_count += 1;
|
self.diagnostics_update_count += 1;
|
||||||
self.text.lamport_clock.observe(lamport_timestamp);
|
self.text.lamport_clock.observe(lamport_timestamp);
|
||||||
@ -2530,8 +2533,8 @@ impl BufferSnapshot {
|
|||||||
{
|
{
|
||||||
let mut iterators: Vec<_> = self
|
let mut iterators: Vec<_> = self
|
||||||
.diagnostics
|
.diagnostics
|
||||||
.values()
|
.iter()
|
||||||
.map(|collection| {
|
.map(|(_, collection)| {
|
||||||
collection
|
collection
|
||||||
.range::<T, O>(search_range.clone(), self, true, reversed)
|
.range::<T, O>(search_range.clone(), self, true, reversed)
|
||||||
.peekable()
|
.peekable()
|
||||||
@ -2555,12 +2558,17 @@ impl BufferSnapshot {
|
|||||||
let mut groups = Vec::new();
|
let mut groups = Vec::new();
|
||||||
|
|
||||||
if let Some(language_server_id) = language_server_id {
|
if let Some(language_server_id) = language_server_id {
|
||||||
if let Some(diagnostics) = self.diagnostics.get(&language_server_id) {
|
if let Ok(ix) = self
|
||||||
diagnostics.groups(language_server_id, &mut groups, self);
|
.diagnostics
|
||||||
|
.binary_search_by_key(&language_server_id, |e| e.0)
|
||||||
|
{
|
||||||
|
self.diagnostics[ix]
|
||||||
|
.1
|
||||||
|
.groups(language_server_id, &mut groups, self);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (&language_server_id, diagnostics) in self.diagnostics.iter() {
|
for (language_server_id, diagnostics) in self.diagnostics.iter() {
|
||||||
diagnostics.groups(language_server_id, &mut groups, self);
|
diagnostics.groups(*language_server_id, &mut groups, self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2581,8 +2589,8 @@ impl BufferSnapshot {
|
|||||||
O: 'a + FromAnchor,
|
O: 'a + FromAnchor,
|
||||||
{
|
{
|
||||||
self.diagnostics
|
self.diagnostics
|
||||||
.values()
|
.iter()
|
||||||
.flat_map(move |set| set.group(group_id, self))
|
.flat_map(move |(_, set)| set.group(group_id, self))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn diagnostics_update_count(&self) -> usize {
|
pub fn diagnostics_update_count(&self) -> usize {
|
||||||
|
@ -9,7 +9,7 @@ path = "src/rope.rs"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bromberg_sl2 = { git = "https://github.com/zed-industries/bromberg_sl2", rev = "950bc5482c216c395049ae33ae4501e08975f17f" }
|
bromberg_sl2 = { git = "https://github.com/zed-industries/bromberg_sl2", rev = "950bc5482c216c395049ae33ae4501e08975f17f" }
|
||||||
smallvec = { version = "1.6", features = ["union"] }
|
smallvec = { workspace = true }
|
||||||
sum_tree = { path = "../sum_tree" }
|
sum_tree = { path = "../sum_tree" }
|
||||||
arrayvec = "0.7.1"
|
arrayvec = "0.7.1"
|
||||||
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
||||||
|
@ -25,7 +25,7 @@ log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
|||||||
postage = { workspace = true }
|
postage = { workspace = true }
|
||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
serde_derive = { workspace = true }
|
serde_derive = { workspace = true }
|
||||||
smallvec = { version = "1.6", features = ["union"] }
|
smallvec = { workspace = true }
|
||||||
smol = "1.2"
|
smol = "1.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
@ -10,4 +10,4 @@ doctest = false
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
smallvec = { version = "1.6", features = ["union"] }
|
smallvec = { workspace = true }
|
||||||
|
@ -17,7 +17,7 @@ theme = { path = "../theme" }
|
|||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
alacritty_terminal = { git = "https://github.com/zed-industries/alacritty", rev = "a51dbe25d67e84d6ed4261e640d3954fbdd9be45" }
|
alacritty_terminal = { git = "https://github.com/zed-industries/alacritty", rev = "a51dbe25d67e84d6ed4261e640d3954fbdd9be45" }
|
||||||
procinfo = { git = "https://github.com/zed-industries/wezterm", rev = "5cd757e5f2eb039ed0c6bb6512223e69d5efc64d", default-features = false }
|
procinfo = { git = "https://github.com/zed-industries/wezterm", rev = "5cd757e5f2eb039ed0c6bb6512223e69d5efc64d", default-features = false }
|
||||||
smallvec = { version = "1.6", features = ["union"] }
|
smallvec = { workspace = true }
|
||||||
smol = "1.2.5"
|
smol = "1.2.5"
|
||||||
mio-extras = "2.0.6"
|
mio-extras = "2.0.6"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
|
@ -21,7 +21,7 @@ workspace = { path = "../workspace" }
|
|||||||
db = { path = "../db" }
|
db = { path = "../db" }
|
||||||
procinfo = { git = "https://github.com/zed-industries/wezterm", rev = "5cd757e5f2eb039ed0c6bb6512223e69d5efc64d", default-features = false }
|
procinfo = { git = "https://github.com/zed-industries/wezterm", rev = "5cd757e5f2eb039ed0c6bb6512223e69d5efc64d", default-features = false }
|
||||||
terminal = { path = "../terminal" }
|
terminal = { path = "../terminal" }
|
||||||
smallvec = { version = "1.6", features = ["union"] }
|
smallvec = { workspace = true }
|
||||||
smol = "1.2.5"
|
smol = "1.2.5"
|
||||||
mio-extras = "2.0.6"
|
mio-extras = "2.0.6"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
|
@ -24,7 +24,7 @@ log = { version = "0.4.16", features = ["kv_unstable_serde"] }
|
|||||||
parking_lot = "0.11"
|
parking_lot = "0.11"
|
||||||
postage = { workspace = true }
|
postage = { workspace = true }
|
||||||
rand = { version = "0.8.3", optional = true }
|
rand = { version = "0.8.3", optional = true }
|
||||||
smallvec = { version = "1.6", features = ["union"] }
|
smallvec = { workspace = true }
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
regex = "1.5"
|
regex = "1.5"
|
||||||
|
|
||||||
|
@ -16,4 +16,4 @@ settings = { path = "../settings" }
|
|||||||
workspace = { path = "../workspace" }
|
workspace = { path = "../workspace" }
|
||||||
project = { path = "../project" }
|
project = { path = "../project" }
|
||||||
|
|
||||||
smallvec = { version = "1.6", features = ["union"] }
|
smallvec = { workspace = true }
|
||||||
|
@ -47,7 +47,7 @@ postage = { workspace = true }
|
|||||||
serde = { workspace = true }
|
serde = { workspace = true }
|
||||||
serde_derive = { workspace = true }
|
serde_derive = { workspace = true }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
smallvec = { version = "1.6", features = ["union"] }
|
smallvec = { workspace = true }
|
||||||
indoc = "1.0.4"
|
indoc = "1.0.4"
|
||||||
uuid = { version = "1.1.2", features = ["v4"] }
|
uuid = { version = "1.1.2", features = ["v4"] }
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ serde_derive = { workspace = true }
|
|||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
serde_path_to_error = "0.1.4"
|
serde_path_to_error = "0.1.4"
|
||||||
simplelog = "0.9"
|
simplelog = "0.9"
|
||||||
smallvec = { version = "1.6", features = ["union"] }
|
smallvec = { workspace = true }
|
||||||
smol = "1.2.5"
|
smol = "1.2.5"
|
||||||
tempdir = { version = "0.3.7" }
|
tempdir = { version = "0.3.7" }
|
||||||
thiserror = "1.0.29"
|
thiserror = "1.0.29"
|
||||||
|
Loading…
Reference in New Issue
Block a user