From: João Távora Date: Wed, 20 Sep 2023 23:03:32 +0000 (+0100) Subject: Flymake: more fixes to flymake--highlight-line X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=8b1947ffdd9d9eae26a308f0abaac45e06baac22;p=emacs.git Flymake: more fixes to flymake--highlight-line Make it robust to diagonstics with invalid bounds. * lisp/progmodes/flymake.el (flymake--highlight-line): Robustify. --- diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el index 1f55df47a46..30dc749349b 100644 --- a/lisp/progmodes/flymake.el +++ b/lisp/progmodes/flymake.el @@ -757,9 +757,9 @@ Return nil or the overlay created." (setq beg a end b)))) (setf (flymake--diag-beg diagnostic) beg (flymake--diag-end diagnostic) end) - ;; Try to fix the remedy the situation if there is the same - ;; diagnostic is already registered in the same place, which only - ;; happens for clashes between domestic and foreign diagnostics + ;; Try to remedy the situation if the same diagnostic is already + ;; registered in the same place. This happens for clashes between + ;; domestic and foreign diagnostics (cl-loop for e in (flymake-diagnostics beg end) for eov = (flymake--diag-overlay e) when (flymake--equal-diagnostic-p e diagnostic) @@ -778,7 +778,12 @@ Return nil or the overlay created." (flymake--diag-end e) (flymake--diag-orig-end e)) (flymake--delete-overlay eov))) - (setq ov (make-overlay end beg)) + (setq ov (make-overlay beg end)) + (when (= (overlay-start ov) (overlay-end ov)) + ;; Some backends report diagnostics with invalid bounds. Don't + ;; bother. + (delete-overlay ov) + (cl-return-from flymake--highlight-line nil)) (setf (flymake--diag-beg diagnostic) (overlay-start ov) (flymake--diag-end diagnostic) (overlay-end ov)) ;; First set `category' in the overlay