Fix #4501: Auto adjust stale diagnostic ranges on document changes#4513
Fix #4501: Auto adjust stale diagnostic ranges on document changes#4513necto wants to merge 18 commits intoemacs-lsp:masterfrom
Conversation
This map keeps track of overlays guarding the diagnostic ranges
Nonetheless it actually works on CI at the moment: https://github.com/emacs-lsp/lsp-mode/actions/runs/10130730283/job/28012482598?pr=4513
|
It is also compatible with the experimental support for code snippets inside org-mode documents, see |
|
Can you resolve conflicts? Thank you! |
done |
|
I tried this PR and when I add/remove a line (regardless of whether that line is in front of or behind the diagnostic) the diagnostics move for a split second but then completely disappear. I've checked |
|
Hi @msrd0 |
|
@necto my emacs config is here: https://gitlab.com/msrd0/dotfiles/-/blob/master/HOME/.emacs.d/init.el?ref_type=heads#L63 Here's a video of the problem: 2025_02_26_1517.webmAs you can see, after I made sure there's an error in the file, everytime I save the error appears, and after I add a newline, the error disappears a short time after I made that edit, and only reappears when I save (emacs tells you at the bottom of the screen when it saves the file). |
To keep the diagnostic ranges actual after document edits and before LSP sends an update (can take multiple seconds or even minutes for SonarLint C++ analysis), allocate an overlay for each diagnostic and use it as the reference for its range.
This change works well together with #4512, which spares the LSP server from playing catch-up with the user modifications.
lsp-diagnosticsandlsp--get-buffer-diagnosticsnow have an additional optional argument:update-ranges?that refreshes the diagnostic ranges.This fixes #4501.