diff options
| author | João Távora | 2026-01-04 02:55:04 +0000 |
|---|---|---|
| committer | João Távora | 2026-01-04 02:58:55 +0000 |
| commit | 6696a738b4c348df55d0de8deb6f45b1eabe2c31 (patch) | |
| tree | 7361568cb11724e6560c14400645421891fac1a3 | |
| parent | c1b8a00da923c0c88821675537f173d630ddb8b3 (diff) | |
| download | emacs-6696a738b4c348df55d0de8deb6f45b1eabe2c31.tar.gz emacs-6696a738b4c348df55d0de8deb6f45b1eabe2c31.zip | |
Eglot: fix thinko in recent diagnostics logic change
If the pushed diagnostics are outdated and we have pulled diagnostics,
we want to report them. And if the pushed diagnostics are up to date,
we want to report them along with any pulled ones. The do-nothing
update happens only if the pulled response indicated so explicitly or if
there are no pulled diagnostics and the pushed ones are out-of-date.
* lisp/progmodes/eglot.el (eglot--flymake-report): Tweak.
| -rw-r--r-- | lisp/progmodes/eglot.el | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index b2dd76f0ea8..979de22c1df 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el | |||
| @@ -3291,33 +3291,35 @@ When response arrives call registered `eglot--flymake-report-fn'." | |||
| 3291 | (remove origin (eglot--managed-buffers server)))))))) | 3291 | (remove origin (eglot--managed-buffers server)))))))) |
| 3292 | 3292 | ||
| 3293 | (cl-defun eglot--flymake-report | 3293 | (cl-defun eglot--flymake-report |
| 3294 | (&optional void | 3294 | (&optional keep |
| 3295 | &aux | 3295 | &aux |
| 3296 | (diags (append (car eglot--pulled-diagnostics) | 3296 | (pushed-docver (cadr eglot--pushed-diagnostics)) |
| 3297 | (car eglot--pushed-diagnostics))) | 3297 | (pushed-outdated-p (and pushed-docver (< pushed-docver eglot--docver)))) |
| 3298 | (version (cadr eglot--pushed-diagnostics))) | ||
| 3299 | "Push previously collected diagnostics to `eglot--flymake-report-fn'. | 3298 | "Push previously collected diagnostics to `eglot--flymake-report-fn'. |
| 3300 | If VOID, knowingly push a dummy do-nothing update." | 3299 | If KEEP, knowingly push a dummy do-nothing update." |
| 3301 | (unless eglot--flymake-report-fn | 3300 | (unless eglot--flymake-report-fn |
| 3302 | ;; Occasionally called from contexts where report-fn not setup, such | 3301 | ;; Occasionally called from contexts where report-fn not setup, such |
| 3303 | ;; as a `didOpen''ed but yet undisplayed buffer. | 3302 | ;; as a `didOpen''ed but yet undisplayed buffer. |
| 3304 | (cl-return-from eglot--flymake-report)) | 3303 | (cl-return-from eglot--flymake-report)) |
| 3305 | (eglot--widening | 3304 | (eglot--widening |
| 3306 | (if (or void (and version (< version eglot--docver))) | 3305 | (if (or keep (and (null eglot--pulled-diagnostics) pushed-outdated-p)) |
| 3307 | ;; Here, we don't have anything interesting to give to Flymake: we | 3306 | ;; Here, we don't have anything interesting to give to |
| 3308 | ;; just want to keep whatever diagnostics it has annotated in the | 3307 | ;; Flymake. Either a textDocument/diagnostics response |
| 3309 | ;; buffer. However, as a nice-to-have, we still want to signal | 3308 | ;; specifically told use that nothing changed, or |
| 3310 | ;; we're alive and clear a possible "Wait" state. We hackingly | 3309 | ;; `flymake-start' kicked in before server had a chance to |
| 3311 | ;; achieve this by reporting an empty list and making sure it | 3310 | ;; push something. We just want to keep whatever diagnostics |
| 3312 | ;; pertains to a 0-length region. | 3311 | ;; it has annotated in the buffer but as a nice-to-have, we |
| 3312 | ;; want to signal we're alive and clear a possible "Wait" | ||
| 3313 | ;; state. We hackingly achieve this by reporting an empty | ||
| 3314 | ;; list and making sure it pertains to a 0-length region. | ||
| 3313 | (funcall eglot--flymake-report-fn nil | 3315 | (funcall eglot--flymake-report-fn nil |
| 3314 | :region (cons (point-min) (point-min))) | 3316 | :region (cons (point-min) (point-min))) |
| 3315 | (funcall eglot--flymake-report-fn diags | 3317 | ;; Using :region keyword always forces Flymake to delete them |
| 3316 | ;; If the buffer hasn't changed since last | 3318 | ;; (github#159). |
| 3317 | ;; call to the report function, flymake won't | 3319 | (funcall eglot--flymake-report-fn |
| 3318 | ;; delete old diagnostics. Using :region | 3320 | (append (car eglot--pulled-diagnostics) |
| 3319 | ;; keyword forces flymake to delete | 3321 | (unless pushed-outdated-p |
| 3320 | ;; them (github#159). | 3322 | (car eglot--pushed-diagnostics))) |
| 3321 | :region (cons (point-min) (point-max)))))) | 3323 | :region (cons (point-min) (point-max)))))) |
| 3322 | 3324 | ||
| 3323 | (defun eglot-xref-backend () "Eglot xref backend." 'eglot) | 3325 | (defun eglot-xref-backend () "Eglot xref backend." 'eglot) |