From df669c5a11f6667de52b0467cda815a5a6e6035d Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Tue, 21 Mar 2023 16:24:29 -0700 Subject: [PATCH] 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 ++ .../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) =-= -- 2.39.5