]> git.eshelyaron.com Git - emacs.git/commitdiff
Properly remove stale Flymake diagnostics on :region reports
authorJoão Távora <joaotavora@gmail.com>
Sun, 10 Feb 2019 21:38:46 +0000 (21:38 +0000)
committerJoão Távora <joaotavora@gmail.com>
Sun, 10 Feb 2019 21:38:46 +0000 (21:38 +0000)
Among other bugs fixed, modifying a list structure while iterating it
is a no-no.  This would again cause duplicate diagnostics.  See
https://github.com/joaotavora/eglot/issues/223 for an example.

* lisp/progmodes/flymake.el (Version): Bump to 1.0.5
(flymake--handle-report): Use cl-loop.

lisp/progmodes/flymake.el

index 15a4d259859abf55c1cb1f22640e45434825e4fa..d991ccafc98994f354e660f6c7841092ad3f3eb0 100644 (file)
@@ -4,7 +4,7 @@
 
 ;; Author:  Pavel Kobyakov <pk_at_work@yahoo.com>
 ;; Maintainer: João Távora <joaotavora@gmail.com>
-;; Version: 1.0.4
+;; Version: 1.0.5
 ;; Package-Requires: ((emacs "26.1"))
 ;; Keywords: c languages tools
 
@@ -742,14 +742,13 @@ report applies to that region."
           ;; the associated overlay.
           (cond
            (region
-            (dolist (diag (flymake--backend-state-diags state))
-              (let ((diag-beg (flymake--diag-beg diag))
-                    (diag-end (flymake--diag-beg diag)))
-                (when (and (< diag-beg (cdr region))
-                           (> diag-end (car region)))
-                  (delete-overlay (flymake--diag-overlay diag))
-                  (setf (flymake--backend-state-diags state)
-                        (delq diag (flymake--backend-state-diags state)))))))
+            (cl-loop for diag in (flymake--backend-state-diags state)
+                     if (or (> (flymake--diag-end diag) (car region))
+                            (< (flymake--diag-beg diag) (cdr region)))
+                     do (delete-overlay (flymake--diag-overlay diag))
+                     else collect diag into surviving
+                     finally (setf (flymake--backend-state-diags state)
+                                   surviving)))
            (first-report
             (dolist (diag (flymake--backend-state-diags state))
               (delete-overlay (flymake--diag-overlay diag)))