Tags: patch
I wasn't sure if these should be two separate bugs, so I separated them just in case.
* lisp/progmodes/c-ts-mode.el(c-ts-mode--indent-styles): Fix indentation
in block statements for cases when the first-sibling(s) are comments or
nested keywords (else_clause/do while).
Bug: The first statement in a compound statement that is preceded by a
comment (or multiple comments) isn't indented.
For example, the `if` statement isnt indented in the following code in
`c-ts-mode` using `linux` style.
int main() {
while (true) { /* foo */
if (true) { // this line isnt indented
puts ("Hello"); // and this isnt either
}
}
}
* lisp/progmodes/c-ts-mode.el(c-ts-mode--indent-styles): Fix indentation
for else_clause and do-while in bracket-less block statements using
`linux` style.
Bug: There is no matching indent rule for bracket-less else_clause
statements and the "while" in a bracket-less do-while statement is
indented to the same level as the do body.
To reproduce, using `linux` style in `c-ts-mode`.
int main() {
if (true)
puts("Hello");
else
puts("No matched rule!");
do
puts("Hello");
while (indented_as_part_of_block);
}
In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.33, cairo version 1.16.0) of 2023-11-18 built on noah-X580VD
Repository revision: 47b497b4dac91e5ea56102018223bdeb5e21a93b
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: Ubuntu 22.04.3 LTS
Configured using:
'configure --prefix=/usr/local --with-modules --with-tree-sitter
--with-threads --with-x-toolkit=gtk3 --with-xwidgets --with-gnutls
--with-json --with-mailutils --with-jpeg --with-png --with-rsvg
--with-tiff --with-xml2 --with-xpm --with-imagemagick CC=gcc-12
CXX=gcc-12'