From 8b1947ffdd9d9eae26a308f0abaac45e06baac22 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Thu, 21 Sep 2023 00:03:32 +0100 Subject: [PATCH] Flymake: more fixes to flymake--highlight-line Make it robust to diagonstics with invalid bounds. * lisp/progmodes/flymake.el (flymake--highlight-line): Robustify. --- lisp/progmodes/flymake.el | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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 -- 2.39.2