]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix 'fill-paragraph' in 'yaml-ts-mode'
authorGraham Marlow <graham@mgmarlow.com>
Tue, 30 Jan 2024 01:16:04 +0000 (17:16 -0800)
committerEshel Yaron <me@eshelyaron.com>
Sun, 4 Feb 2024 11:00:55 +0000 (12:00 +0100)
* lisp/textmodes/yaml-ts-mode.el (yaml-ts-mode--fill-paragraph):
Avoid 'fill-paragraph' when outside of block_scalar or comment
nodes.  (Bug#68781)

(cherry picked from commit 4adb4b2ac507636a82373ed1323dabcb7ee9258d)

lisp/textmodes/yaml-ts-mode.el

index c0185457bc2a98a284002b3d7682b0c6a2a64eaa..a8cb504ef03c4aab0e7cc74e4ec1bfe667a90712 100644 (file)
@@ -128,7 +128,7 @@ boundaries.  JUSTIFY is passed to `fill-paragraph'."
   (save-restriction
     (widen)
     (let ((node (treesit-node-at (point))))
-      (when (string= "block_scalar" (treesit-node-type node))
+      (if (member (treesit-node-type node) '("block_scalar" "comment"))
         (let* ((start (treesit-node-start node))
                (end (treesit-node-end node))
                (start-marker (point-marker))
@@ -138,7 +138,8 @@ boundaries.  JUSTIFY is passed to `fill-paragraph'."
             (forward-line)
             (move-marker start-marker (point))
             (narrow-to-region (point) end))
-          (fill-region start-marker end justify))))))
+          (fill-region start-marker end justify))
+        t))))
 
 ;;;###autoload
 (define-derived-mode yaml-ts-mode text-mode "YAML"