diff options
| author | Yuan Fu | 2023-03-21 16:24:29 -0700 |
|---|---|---|
| committer | Yuan Fu | 2023-03-21 16:24:29 -0700 |
| commit | df669c5a11f6667de52b0467cda815a5a6e6035d (patch) | |
| tree | f2207635b4792d1890557285ac6da8e2228e0ba7 | |
| parent | 8b6a0de964d61cb8d57ed3fe65086fa305a3c53e (diff) | |
| download | emacs-df669c5a11f6667de52b0467cda815a5a6e6035d.tar.gz emacs-df669c5a11f6667de52b0467cda815a5a6e6035d.zip | |
Add missing indent rule for c-ts-mode
* lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): New rule for case.
* test/lisp/progmodes/c-ts-mode-resources/indent.erts: New test.
| -rw-r--r-- | lisp/progmodes/c-ts-mode.el | 2 | ||||
| -rw-r--r-- | test/lisp/progmodes/c-ts-mode-resources/indent.erts | 30 |
2 files changed, 32 insertions, 0 deletions
diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 659db46dc12..f70869c10bb 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el | |||
| @@ -434,6 +434,8 @@ MODE is either `c' or `cpp'." | |||
| 434 | ((parent-is "while_statement") standalone-parent c-ts-mode-indent-offset) | 434 | ((parent-is "while_statement") standalone-parent c-ts-mode-indent-offset) |
| 435 | ((parent-is "do_statement") standalone-parent c-ts-mode-indent-offset) | 435 | ((parent-is "do_statement") standalone-parent c-ts-mode-indent-offset) |
| 436 | 436 | ||
| 437 | ((parent-is "case_statement") standalone-parent c-ts-mode-indent-offset) | ||
| 438 | |||
| 437 | ,@(when (eq mode 'cpp) | 439 | ,@(when (eq mode 'cpp) |
| 438 | `(((node-is "field_initializer_list") parent-bol ,(* c-ts-mode-indent-offset 2))))))) | 440 | `(((node-is "field_initializer_list") parent-bol ,(* c-ts-mode-indent-offset 2))))))) |
| 439 | `((gnu | 441 | `((gnu |
diff --git a/test/lisp/progmodes/c-ts-mode-resources/indent.erts b/test/lisp/progmodes/c-ts-mode-resources/indent.erts index 9e28ef203fd..5cdefe2122c 100644 --- a/test/lisp/progmodes/c-ts-mode-resources/indent.erts +++ b/test/lisp/progmodes/c-ts-mode-resources/indent.erts | |||
| @@ -188,6 +188,36 @@ int main() | |||
| 188 | } | 188 | } |
| 189 | =-=-= | 189 | =-=-= |
| 190 | 190 | ||
| 191 | Name: Switch-Case statement | ||
| 192 | |||
| 193 | =-= | ||
| 194 | int main() { | ||
| 195 | switch (a) { | ||
| 196 | case 1: | ||
| 197 | b = c; | ||
| 198 | return 10; | ||
| 199 | case 2: | ||
| 200 | { | ||
| 201 | a = b; | ||
| 202 | return 12 | ||
| 203 | } | ||
| 204 | } | ||
| 205 | } | ||
| 206 | =-= | ||
| 207 | int main() { | ||
| 208 | switch (a) { | ||
| 209 | case 1: | ||
| 210 | b = c; | ||
| 211 | return 10; | ||
| 212 | case 2: | ||
| 213 | { | ||
| 214 | a = b; | ||
| 215 | return 12 | ||
| 216 | } | ||
| 217 | } | ||
| 218 | } | ||
| 219 | =-=-= | ||
| 220 | |||
| 191 | Name: Multiline Block Comments 1 (bug#60270) | 221 | Name: Multiline Block Comments 1 (bug#60270) |
| 192 | 222 | ||
| 193 | =-= | 223 | =-= |