]> git.eshelyaron.com Git - emacs.git/commitdiff
Flymake: protect against problematic invalid diagnostics
authorJoão Távora <joaotavora@gmail.com>
Thu, 26 Oct 2023 13:20:41 +0000 (14:20 +0100)
committerJoão Távora <joaotavora@gmail.com>
Thu, 26 Oct 2023 13:21:04 +0000 (14:21 +0100)
If a backend reports a diagnostic which is out of bounds, it still
lives in flymake--state and will still be cleaned up in the next run
of flymake--publish-diagnostics.  But if flymake--highlight-line
doesn't give it an overlay (which it didn't until now), things will
break afterwards.

See bug#66759 and https://github.com/joaotavora/eglot/discussions/1311

* lisp/progmodes/flymake.el (flymake--highlight-line): Set
flymake--diag-overlay earlier.
(Version): Bump to 1.3.7.

lisp/progmodes/flymake.el

index b27e6527f81f3447d41422617a8a48a8c3c83fe2..fb0005176557ac116f68403bbb41d6422791989d 100644 (file)
@@ -4,7 +4,7 @@
 
 ;; Author: Pavel Kobyakov <pk_at_work@yahoo.com>
 ;; Maintainer: João Távora <joaotavora@gmail.com>
-;; Version: 1.3.6
+;; Version: 1.3.7
 ;; Keywords: c languages tools
 ;; Package-Requires: ((emacs "26.1") (eldoc "1.14.0") (project "0.7.1"))
 
@@ -809,6 +809,7 @@ Return nil or the overlay created."
                         (flymake--diag-orig-end e))
                   (flymake--delete-overlay eov)))
     (setq ov (make-overlay beg end))
+    (setf (flymake--diag-overlay diagnostic) ov)
     (when (= (overlay-start ov) (overlay-end ov))
       ;; Some backends report diagnostics with invalid bounds.  Don't
       ;; bother.
@@ -863,7 +864,6 @@ Return nil or the overlay created."
     (overlay-put ov 'evaporate t)
     (overlay-put ov 'flymake-overlay t)
     (overlay-put ov 'flymake-diagnostic diagnostic)
-    (setf (flymake--diag-overlay diagnostic) ov)
     ;; Handle `flymake-show-diagnostics-at-end-of-line'
     ;;
     (when flymake-show-diagnostics-at-end-of-line