diff options
author | Michael Davis | 2023-08-27 18:32:17 +0000 |
---|---|---|
committer | Blaž Hrastnik | 2024-02-25 15:12:43 +0000 |
commit | 8141a4a1ab78084df94c19e6225fc3c64a05b88f (patch) | |
tree | 2ff8039cbdb1f282e7451ae0140f7576cc6e64e5 /helix-view/src/editor.rs | |
parent | dfa5382c51978c6a582d4586c65aa0f677be2ee8 (diff) |
LSP: Key diagnostics off file path instead of URI
URIs need to be normalized to be comparable. For example a language
server could send a URI for a path containing '+' as '%2B' but we might
encode this in something like 'Document::url' as just '+'. We can
normalize the URI straight into a PathBuf though since this is the only
value we compare these diagnostics URIs against. This also covers
edge-cases like windows drive letter capitalization.
Diffstat (limited to 'helix-view/src/editor.rs')
-rw-r--r-- | helix-view/src/editor.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index fffbe620..f46a0d6a 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -914,7 +914,7 @@ pub struct Editor { pub macro_recording: Option<(char, Vec<KeyEvent>)>, pub macro_replaying: Vec<char>, pub language_servers: helix_lsp::Registry, - pub diagnostics: BTreeMap<lsp::Url, Vec<(lsp::Diagnostic, usize)>>, + pub diagnostics: BTreeMap<PathBuf, Vec<(lsp::Diagnostic, usize)>>, pub diff_providers: DiffProviderRegistry, pub debugger: Option<dap::Client>, @@ -1815,7 +1815,7 @@ impl Editor { /// Returns all supported diagnostics for the document pub fn doc_diagnostics<'a>( language_servers: &'a helix_lsp::Registry, - diagnostics: &'a BTreeMap<lsp::Url, Vec<(lsp::Diagnostic, usize)>>, + diagnostics: &'a BTreeMap<PathBuf, Vec<(lsp::Diagnostic, usize)>>, document: &Document, ) -> impl Iterator<Item = helix_core::Diagnostic> + 'a { Editor::doc_diagnostics_with_filter(language_servers, diagnostics, document, |_, _| true) @@ -1825,7 +1825,7 @@ impl Editor { /// filtered by `filter` which is invocated with the raw `lsp::Diagnostic` and the language server id it came from pub fn doc_diagnostics_with_filter<'a>( language_servers: &'a helix_lsp::Registry, - diagnostics: &'a BTreeMap<lsp::Url, Vec<(lsp::Diagnostic, usize)>>, + diagnostics: &'a BTreeMap<PathBuf, Vec<(lsp::Diagnostic, usize)>>, document: &Document, filter: impl Fn(&lsp::Diagnostic, usize) -> bool + 'a, @@ -1834,8 +1834,7 @@ impl Editor { let language_config = document.language.clone(); document .path() - .and_then(|path| url::Url::from_file_path(path).ok()) // TODO log error? - .and_then(|uri| diagnostics.get(&uri)) + .and_then(|path| diagnostics.get(path)) .map(|diags| { diags.iter().filter_map(move |(diagnostic, lsp_id)| { let ls = language_servers.get_by_id(*lsp_id)?; |