Fix c-ts-mode indentation
Not the subject of it, but mentioned in bug#61893. * lisp/progmodes/c-ts-mode.el (c-ts-mode--anchor-prev-sibling): Skip the sibling if it doesn't start on it's own line. * test/lisp/progmodes/c-ts-mode-resources/indent.erts: New test.
This commit is contained in:
parent
75cdc1afbe
commit
7292b24c80
2 changed files with 35 additions and 11 deletions
|
@ -284,17 +284,25 @@ PARENT and BOL are like other anchor functions."
|
||||||
(treesit-node-first-child-for-pos parent bol) t)
|
(treesit-node-first-child-for-pos parent bol) t)
|
||||||
(treesit-node-child parent -1 t)))
|
(treesit-node-child parent -1 t)))
|
||||||
(continue t))
|
(continue t))
|
||||||
(while (and prev-sibling continue)
|
(save-excursion
|
||||||
(pcase (treesit-node-type prev-sibling)
|
(while (and prev-sibling continue)
|
||||||
;; Get the statement in the label.
|
(pcase (treesit-node-type prev-sibling)
|
||||||
("labeled_statement"
|
;; Get the statement in the label.
|
||||||
(setq prev-sibling (treesit-node-child prev-sibling 2)))
|
("labeled_statement"
|
||||||
;; Get the last statement in the preproc. Tested by
|
(setq prev-sibling (treesit-node-child prev-sibling 2)))
|
||||||
;; "Prev-Sibling When Prev-Sibling is Preproc" test.
|
;; Get the last statement in the preproc. Tested by
|
||||||
((or "preproc_if" "preproc_ifdef" "preproc_elif" "preproc_else")
|
;; "Prev-Sibling When Prev-Sibling is Preproc" test.
|
||||||
(setq prev-sibling (treesit-node-child prev-sibling -2)))
|
((or "preproc_if" "preproc_ifdef" "preproc_elif" "preproc_else")
|
||||||
;; Don't do anything special.
|
(setq prev-sibling (treesit-node-child prev-sibling -2)))
|
||||||
(_ (setq continue nil))))
|
;; If the start of the previous sibling isn't at the
|
||||||
|
;; beginning of a line, something's probably not quite
|
||||||
|
;; right, go a step further.
|
||||||
|
(_ (goto-char (treesit-node-start prev-sibling))
|
||||||
|
(if (looking-back (rx bol (* whitespace))
|
||||||
|
(line-beginning-position))
|
||||||
|
(setq continue nil)
|
||||||
|
(setq prev-sibling
|
||||||
|
(treesit-node-prev-sibling prev-sibling)))))))
|
||||||
;; This could be nil if a) there is no prev-sibling or b)
|
;; This could be nil if a) there is no prev-sibling or b)
|
||||||
;; prev-sibling doesn't have a child.
|
;; prev-sibling doesn't have a child.
|
||||||
(treesit-node-start prev-sibling)))
|
(treesit-node-start prev-sibling)))
|
||||||
|
|
|
@ -402,3 +402,19 @@ int main()
|
||||||
|
|
|
|
||||||
}
|
}
|
||||||
=-=-=
|
=-=-=
|
||||||
|
|
||||||
|
Name: Prev-Sibling But Not Trailing Comment
|
||||||
|
|
||||||
|
=-=
|
||||||
|
static int
|
||||||
|
required_matrix_height (struct window *w)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_WINDOW_SYSTEM
|
||||||
|
if (FRAME_WINDOW_P (f))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif /* Don't align to this comment. */
|
||||||
|
|
|
||||||
|
}
|
||||||
|
=-=-=
|
||||||
|
|
Loading…
Add table
Reference in a new issue