emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 53333132e47: Fix c-ts-common--fill-paragraph for C


From: Yuan Fu
Subject: master 53333132e47: Fix c-ts-common--fill-paragraph for C
Date: Fri, 26 Apr 2024 22:57:24 -0400 (EDT)

branch: master
commit 53333132e47589c59331a7b8b3afb5ce964aed99
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    Fix c-ts-common--fill-paragraph for C
    
    This should fix the failing filling test for c-ts-mode.
    
    * lisp/progmodes/c-ts-common.el (c-ts-common--fill-paragraph): Don't
    go back to indentation.
---
 lisp/progmodes/c-ts-common.el | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/lisp/progmodes/c-ts-common.el b/lisp/progmodes/c-ts-common.el
index cc8254c5701..b1520db22e9 100644
--- a/lisp/progmodes/c-ts-common.el
+++ b/lisp/progmodes/c-ts-common.el
@@ -123,12 +123,16 @@ ARG is passed to `fill-paragraph'."
     (let ((node (treesit-node-at (point))))
       (when (string-match-p c-ts-common--comment-regexp
                             (treesit-node-type node))
-        (if (save-excursion
-              (goto-char (treesit-node-start node))
-              ;; In rust, NODE will be the body of a comment excluding
-              ;; the //, so we need to go to BOL to check for //.
-              (back-to-indentation)
-              (looking-at "//"))
+        (if (or (save-excursion
+                  (goto-char (treesit-node-start node))
+                  (looking-at "//"))
+                ;; In rust, NODE will be the body of a comment, and the
+                ;; parent will be the whole comment.
+                (if-let ((start (treesit-node-start
+                                 (treesit-node-parent node))))
+                    (save-excursion
+                      (goto-char start)
+                      (looking-at "//"))))
             (fill-comment-paragraph arg)
           (c-ts-common--fill-block-comment arg)))
       ;; Return t so `fill-paragraph' doesn't attempt to fill by



reply via email to

[Prev in Thread] Current Thread [Next in Thread]