]> git.eshelyaron.com Git - emacs.git/commit
Fix c-ts-mode indentation (bug#67357)
authornverno <noah.v.peart@gmail.com>
Wed, 22 Nov 2023 00:33:04 +0000 (16:33 -0800)
committerEshel Yaron <me@eshelyaron.com>
Mon, 11 Dec 2023 06:42:18 +0000 (07:42 +0100)
commitfad1e687637b8f772da404f00fce7424e4d59083
tree9cb4418c97c5936f1a3815eec96fd87d1c90c27f
parentb5e9758d89bc3270b38f22e33d584b6e1c0959f6
Fix c-ts-mode indentation (bug#67357)

1. In a compund_statement, we indent the first sibling against the
parent, and the rest siblings against their previous sibling.  But
this strategy falls apart when the first sibling is not on its own
line.  We should regard the first sibling that is on its own line as
the "first sibling"", and indent it against the parent.

2. In linux style, in a do-while statement, if the do-body is
bracket-less, the "while" keyword is indented to the same level as the
do-body.  It should be indented to align with the "do" keyword
instead.

* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--no-prev-standalone-sibling): New function.
(c-ts-mode--indent-styles): Use
c-ts-mode--no-prev-standalone-sibling. Add while keyword indent rule.
* test/lisp/progmodes/c-ts-mode-resources/indent.erts: New tests.

(cherry picked from commit 08fc6bace202a13d93fc76943c41f19acaab9c73)
lisp/progmodes/c-ts-mode.el
test/lisp/progmodes/c-ts-mode-resources/indent.erts