[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 df669c5a11f 1/3: Add missing indent rule for c-ts-mode
From: |
Yuan Fu |
Subject: |
emacs-29 df669c5a11f 1/3: Add missing indent rule for c-ts-mode |
Date: |
Wed, 22 Mar 2023 02:34:33 -0400 (EDT) |
branch: emacs-29
commit df669c5a11f6667de52b0467cda815a5a6e6035d
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>
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.
---
lisp/progmodes/c-ts-mode.el | 2 ++
.../lisp/progmodes/c-ts-mode-resources/indent.erts | 30 ++++++++++++++++++++++
2 files changed, 32 insertions(+)
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'."
((parent-is "while_statement") standalone-parent
c-ts-mode-indent-offset)
((parent-is "do_statement") standalone-parent
c-ts-mode-indent-offset)
+ ((parent-is "case_statement") standalone-parent
c-ts-mode-indent-offset)
+
,@(when (eq mode 'cpp)
`(((node-is "field_initializer_list") parent-bol ,(*
c-ts-mode-indent-offset 2)))))))
`((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()
}
=-=-=
+Name: Switch-Case statement
+
+=-=
+int main() {
+switch (a) {
+case 1:
+b = c;
+return 10;
+case 2:
+{
+a = b;
+return 12
+}
+}
+}
+=-=
+int main() {
+ switch (a) {
+ case 1:
+ b = c;
+ return 10;
+ case 2:
+ {
+ a = b;
+ return 12
+ }
+ }
+}
+=-=-=
+
Name: Multiline Block Comments 1 (bug#60270)
=-=