]> git.eshelyaron.com Git - emacs.git/commit
Fix c-ts-mode indentation for initializer lists (bug#73661)
authorJørgen Kvalsvik <j@lambda.is>
Fri, 4 Oct 2024 19:38:33 +0000 (21:38 +0200)
committerEshel Yaron <me@eshelyaron.com>
Mon, 14 Oct 2024 17:37:52 +0000 (19:37 +0200)
commitd8204db859a1807a4a48bd9dc89f20ed37b008bb
tree8e479577f7b319e98deee2fbbd2627044865173a
parenta4fad8c43409d22e14ce1bf7ea6c46782a7875b1
Fix c-ts-mode indentation for initializer lists (bug#73661)

The intentation behavior differed between c-mode/c++-mode
and *-ts-mode for initializer lists where the first element was
not at beginning-of-line.  The anchor-prev-sibling function gave
up and returned nil, but it should (probably) anchor on the
first element in the initializer list, such as this:

return { v1, v2, ...,
         y1, y2, ... };

c-ts-mode behaved better and figured out how to align, but I
added a test for a similar compound literal to prevent
regressions.

* lisp/progmodes/c-ts-mode.el (c-ts-mode--anchor-prev-sibling):
Anchor at first sibling unless bol is found.

* test/lisp/progmodes/c-ts-mode-resources/indent.erts: New
initializer list and compound literal test.

Copyright-paperwork-exempt: yes
(cherry picked from commit e49b479f8692573379a1ee3417bdda9e1f777888)
lisp/progmodes/c-ts-mode.el
test/lisp/progmodes/c-ts-mode-resources/indent.erts