branch: elpa/swift-mode
commit c664fc2005248482f63dac0eec4e6927179f4f5b
Merge: 4e615b7 773219a
Author: Bozhidar Batsov <bozhidar.bat...@gmail.com>
Commit: Bozhidar Batsov <bozhidar.bat...@gmail.com>

    Merge pull request #51 from ap4y/fix_default_case_indentation
    
    Treat default clause for case statement as a whole with colon in bnf grammar
---
 swift-mode.el             |  4 ++--
 test/indentation-tests.el | 16 ++++++++++++----
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/swift-mode.el b/swift-mode.el
index 609b686..b06ff2d 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -140,7 +140,7 @@
        (case-exps (guard-exp))
        (cases (case-exps ":" insts)
               (cases "case" cases))
-       (switch-body (cases) (cases "default" insts))
+       (switch-body (cases) (cases "default:" insts))
 
        (for-head (in-exp) (op-exp) (for-head ";" for-head))
 
@@ -269,7 +269,7 @@
      (if (smie-rule-parent-p "switch")
          (smie-rule-parent swift-indent-switch-case-offset)))
     (`(:before . ";")
-     (if (smie-rule-parent-p "case" "default")
+     (if (smie-rule-parent-p "case" "default:")
          (smie-rule-parent swift-indent-offset)))
 
     ;; Apply swift-indent-multiline-statement-offset only if
diff --git a/test/indentation-tests.el b/test/indentation-tests.el
index f958732..bb5286b 100644
--- a/test/indentation-tests.el
+++ b/test/indentation-tests.el
@@ -354,13 +354,17 @@ case y:
   "
 {
     switch true {
-|default
+    case y:
+        x
+|default:
     }
 }
 " "
 {
     switch true {
-    |default
+    case y:
+        x
+    |default:
     }
 }
 ")
@@ -369,13 +373,17 @@ case y:
   "
 {
     switch true {
-              |default
+    case y:
+        x
+              |default:
     }
 }
 " "
 {
     switch true {
-    |default
+    case y:
+        x
+    |default:
     }
 }
 ")

Reply via email to