Fix c-ts-mode block comment indentation (bug#60270)
* lisp/progmodes/c-ts-mode.el: (c-ts-mode--comment-2nd-line-anchor): Handle another edge case.
This commit is contained in:
parent
252b2c01af
commit
25a5575f16
1 changed files with 14 additions and 4 deletions
|
@ -294,14 +294,15 @@ PARENT should be a comment node."
|
||||||
(back-to-indentation)
|
(back-to-indentation)
|
||||||
(eq (point) (treesit-node-start parent)))))
|
(eq (point) (treesit-node-start parent)))))
|
||||||
|
|
||||||
(defun c-ts-mode--comment-2nd-line-anchor (&rest _)
|
(defun c-ts-mode--comment-2nd-line-anchor (_n _p bol &rest _)
|
||||||
"Return appropriate anchor for the second line of a comment.
|
"Return appropriate anchor for the second line of a comment.
|
||||||
|
|
||||||
If the first line is /* alone, return the position right after
|
If the first line is /* alone, return the position right after
|
||||||
the star; if the first line is /* followed by some text, return
|
the star; if the first line is /* followed by some text, return
|
||||||
the position right before the text minus 1.
|
the position right before the text minus 1.
|
||||||
|
|
||||||
Use an offset of 1 with this anchor."
|
Use an offset of 1 with this anchor. BOL is the beginning of
|
||||||
|
non-whitespace characters of the current line."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(forward-line -1)
|
(forward-line -1)
|
||||||
(back-to-indentation)
|
(back-to-indentation)
|
||||||
|
@ -310,8 +311,17 @@ Use an offset of 1 with this anchor."
|
||||||
(if (looking-at (rx (* (or " " "\t")) eol))
|
(if (looking-at (rx (* (or " " "\t")) eol))
|
||||||
;; Only /* at the first line.
|
;; Only /* at the first line.
|
||||||
(progn (skip-chars-backward " \t")
|
(progn (skip-chars-backward " \t")
|
||||||
(point))
|
(if (save-excursion
|
||||||
;; There is something after /* at the first line.
|
(goto-char bol)
|
||||||
|
(looking-at (rx "*")))
|
||||||
|
;; The common case. Checked by "Multiline Block
|
||||||
|
;; Comments 4".
|
||||||
|
(point)
|
||||||
|
;; The "Multiline Block Comments 2" test in
|
||||||
|
;; c-ts-mode-resources/indent.erts checks this.
|
||||||
|
(1- (point))))
|
||||||
|
;; There is something after /* at the first line. The
|
||||||
|
;; "Multiline Block Comments 3" test checks this.
|
||||||
(1- (point))))))
|
(1- (point))))))
|
||||||
|
|
||||||
;;; Font-lock
|
;;; Font-lock
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue