bug#81650: [PATCH] Flymake diagnostics are not cleared in yaml-ts-mode when all errors are fixed

James Cherti <[email protected]>
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
When editing a file in yaml-ts-mode (emacs 31 and 32) with
Flymake enabled, resolving all linting errors does not clear
the diagnostic highlights. The previous error overlays
remain visible in the buffer despite the file being
completely valid and passing all yamllint checks.

Steps to Reproduce:

1. Open a YAML file in Emacs using yaml-ts-mode.
2. Ensure Flymake is active and yamllint is available in
    your exec-path.
3. Introduce a syntax or formatting error into the file.
4. Wait for Flymake to run and highlight the error.
5. Fix the error.
6. Wait for Flymake to run again.

The attached patch fixes the issue by moving the (funcall
report-fn diags) call outside of the while loop, ensuring
that Flymake receives the updated empty list and
successfully clears the obsolete diagnostics.

--
James Cherti
GitHub: https://github.com/jamescherti
Website: https://www.jamescherti.com/
0001-Fix-diagnostics-clearing-in-yaml-ts-mode-flymake.patch (text/x-patch, 1.6 KB)
From ad437d1823cf2a3e88c802f725d59aab69c47bb4 Mon Sep 17 00:00:00 2001
From: James Cherti <[email protected]>
Date: Tue, 18 Aug 2026 08:43:26 -0400
Subject: [PATCH] Fix diagnostics clearing in yaml-ts-mode-flymake

* lisp/textmodes/yaml-ts-mode.el (yaml-ts-mode-flymake): Call
the 'report-fn' callback outside the 'while' loop.  This change
ensures that Flymake receives an empty list of diagnostics and
clears old highlights when the YAML file has no linting errors.
---
 lisp/textmodes/yaml-ts-mode.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/textmodes/yaml-ts-mode.el b/lisp/textmodes/yaml-ts-mode.el
index 95fd4b6a78a..a356027c271 100644
--- a/lisp/textmodes/yaml-ts-mode.el
+++ b/lisp/textmodes/yaml-ts-mode.el
@@ -247,12 +247,12 @@ yaml-ts-mode-flymake
                                         (type (if (string= "[warning]" (match-string 3))
                                                   :warning
                                                 :error)))
                                    (push (flymake-make-diagnostic
                                           source beg end type msg)
-                                         diags))
-                                 (funcall report-fn diags))))
+                                         diags)))
+                               (funcall report-fn diags)))
                          (flymake-log :warning "Canceling obsolete check %s" proc))
                      (kill-buffer (process-buffer proc)))))))
         (process-send-region yaml-ts-mode--flymake-process (point-min) (point-max))
         (process-send-eof yaml-ts-mode--flymake-process)))))
 
-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.