Fix c-ts-mode comment indent
authorYuan Fu <casouri@gmail.com>
Tue, 10 Jan 2023 05:46:07 +0000 (21:46 -0800)
committerYuan Fu <casouri@gmail.com>
Tue, 10 Jan 2023 05:46:07 +0000 (21:46 -0800)
* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--comment-2nd-line-matcher): Also make sure PARENT is a
comment node.

lisp/progmodes/c-ts-mode.el

index 898b89b9fce77e60633c378585ed4ede6e7105ca..5c7df4b21413e2be0287d32bf0d6e19ae2fa022f 100644 (file)
@@ -246,10 +246,11 @@ Assumes PARENT is a comment node."
 (defun c-ts-mode--comment-2nd-line-matcher (_n parent &rest _)
   "Matches if point is at the second line of a block comment.
 PARENT should be a comment node."
-  (save-excursion
-    (forward-line -1)
-    (back-to-indentation)
-    (eq (point) (treesit-node-start parent))))
+  (and (equal (treesit-node-type parent) "comment")
+       (save-excursion
+         (forward-line -1)
+         (back-to-indentation)
+         (eq (point) (treesit-node-start parent)))))
 
 (defun c-ts-mode--comment-2nd-line-anchor (&rest _)
   "Return appropriate anchor for the second line of a comment.