diff options
author | Norbert Preining <norbert@preining.info> | 2024-05-02 03:02:55 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2024-05-02 03:02:55 +0000 |
commit | 68c5442089b7c2e61ee14fc3efed490e291a244a (patch) | |
tree | 91d0e68d495b53cb52bb60a3e234da061741067d /support/texlab/crates/diagnostics | |
parent | 6ac3dbed4b71022bd6bb0cc25e8fc3df81198498 (diff) |
CTAN sync 202405020302
Diffstat (limited to 'support/texlab/crates/diagnostics')
-rw-r--r-- | support/texlab/crates/diagnostics/Cargo.toml | 8 | ||||
-rw-r--r-- | support/texlab/crates/diagnostics/src/citations.rs | 2 | ||||
-rw-r--r-- | support/texlab/crates/diagnostics/src/manager.rs | 14 |
3 files changed, 18 insertions, 6 deletions
diff --git a/support/texlab/crates/diagnostics/Cargo.toml b/support/texlab/crates/diagnostics/Cargo.toml index 5a2a7a7e28..1cb09fdec9 100644 --- a/support/texlab/crates/diagnostics/Cargo.toml +++ b/support/texlab/crates/diagnostics/Cargo.toml @@ -8,21 +8,21 @@ rust-version.workspace = true [dependencies] base-db = { path = "../base-db" } -encoding_rs = "0.8.33" +encoding_rs = "0.8.34" encoding_rs_io = "0.1.7" -itertools = "0.12.0" +itertools = "0.12.1" line-index = { path = "../line-index" } log = "0.4.21" multimap = "0.10.0" once_cell = "1.19.0" -regex = "1.10.2" +regex = "1.10.4" rowan = "0.15.15" rustc-hash = "1.1.0" syntax = { path = "../syntax" } url = "2.5.0" [dev-dependencies] -expect-test = "1.4.1" +expect-test = "1.5.0" test-utils = { path = "../test-utils" } [lib] diff --git a/support/texlab/crates/diagnostics/src/citations.rs b/support/texlab/crates/diagnostics/src/citations.rs index 84b9a10b1c..0f09f589be 100644 --- a/support/texlab/crates/diagnostics/src/citations.rs +++ b/support/texlab/crates/diagnostics/src/citations.rs @@ -24,7 +24,7 @@ pub fn detect_undefined_citations<'a>( for citation in &data.semantics.citations { let name = citation.name_text(); - if name != "*" && !entries.contains(name) { + if name != "*" && !entries.contains(name) && !name.contains("#") { let diagnostic = Diagnostic::Tex(citation.name.range, TexError::UndefinedCitation); results .entry(document.uri.clone()) diff --git a/support/texlab/crates/diagnostics/src/manager.rs b/support/texlab/crates/diagnostics/src/manager.rs index 81347410c1..3573bc40f2 100644 --- a/support/texlab/crates/diagnostics/src/manager.rs +++ b/support/texlab/crates/diagnostics/src/manager.rs @@ -1,6 +1,6 @@ use base_db::{deps::Project, util::filter_regex_patterns, Document, Owner, Workspace}; use multimap::MultiMap; -use rustc_hash::FxHashMap; +use rustc_hash::{FxHashMap, FxHashSet}; use url::Url; use crate::types::Diagnostic; @@ -33,6 +33,18 @@ impl Manager { self.chktex.insert(uri, diagnostics); } + /// Removes stale diagnostics for documents that are no longer part of the workspace. + pub fn cleanup(&mut self, workspace: &Workspace) { + let uris = workspace + .iter() + .map(|doc| &doc.uri) + .collect::<FxHashSet<_>>(); + + self.grammar.retain(|uri, _| uris.contains(uri)); + self.chktex.retain(|uri, _| uris.contains(uri)); + self.build_log.retain(|uri, _| uris.contains(uri)); + } + /// Returns all filtered diagnostics for the given workspace. pub fn get(&self, workspace: &Workspace) -> FxHashMap<Url, Vec<Diagnostic>> { let mut results: FxHashMap<Url, Vec<Diagnostic>> = FxHashMap::default(); |