emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

emacs-29 f8d9dc26c78: Fix indentation for else clause in c-ts-mode (bug#


From: Yuan Fu
Subject: emacs-29 f8d9dc26c78: Fix indentation for else clause in c-ts-mode (bug#67417)
Date: Sun, 26 Nov 2023 20:31:04 -0500 (EST)

branch: emacs-29
commit f8d9dc26c78366e1f2de9dd847fe4744f607748d
Author: Yuan Fu <casouri@gmail.com>
Commit: Yuan Fu <casouri@gmail.com>

    Fix indentation for else clause in c-ts-mode (bug#67417)
    
    * lisp/progmodes/c-ts-mode.el:
    (c-ts-mode--indent-styles): Add indentation for children of
    else_clause.
    * test/lisp/progmodes/c-ts-mode-resources/indent.erts:
    (Name): Add test for else-break.  Also make the test such that it
    needs to indent correctly from scratch (rather than maintaining the
    already correct indentation.)
---
 lisp/progmodes/c-ts-mode.el                         |  1 +
 test/lisp/progmodes/c-ts-mode-resources/indent.erts | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 8660b65f309..5975057518e 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -452,6 +452,7 @@ MODE is either `c' or `cpp'."
            ;; These rules are for cases where the body is bracketless.
            ;; Tested by the "Bracketless Simple Statement" test.
            ((parent-is "if_statement") standalone-parent 
c-ts-mode-indent-offset)
+           ((parent-is "else_clause") standalone-parent 
c-ts-mode-indent-offset)
            ((parent-is "for_statement") standalone-parent 
c-ts-mode-indent-offset)
            ((parent-is "while_statement") standalone-parent 
c-ts-mode-indent-offset)
            ((parent-is "do_statement") standalone-parent 
c-ts-mode-indent-offset)
diff --git a/test/lisp/progmodes/c-ts-mode-resources/indent.erts 
b/test/lisp/progmodes/c-ts-mode-resources/indent.erts
index 221b3d809af..bac76fb7378 100644
--- a/test/lisp/progmodes/c-ts-mode-resources/indent.erts
+++ b/test/lisp/progmodes/c-ts-mode-resources/indent.erts
@@ -149,6 +149,21 @@ for (int i = 0;
 
 Name: Bracketless Simple Statement
 
+=-=
+for (int i = 0; i < 5; i++)
+continue;
+
+while (true)
+return 1;
+
+do
+i++;
+while (true)
+
+if (true)
+break;
+else
+break;
 =-=
 for (int i = 0; i < 5; i++)
   continue;
@@ -159,6 +174,11 @@ while (true)
 do
   i++;
 while (true)
+
+if (true)
+  break;
+else
+  break;
 =-=-=
 
 Name: Nested If-Else



reply via email to

[Prev in Thread] Current Thread [Next in Thread]