emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/swift-mode e539ba6 215/496: Improve support for the multi-


From: ELPA Syncer
Subject: [nongnu] elpa/swift-mode e539ba6 215/496: Improve support for the multi-line case statements
Date: Sun, 29 Aug 2021 11:33:38 -0400 (EDT)

branch: elpa/swift-mode
commit e539ba615ec041d24ebbc2abfc27b5e88c113ecd
Author: ap4y <lod@pisem.net>
Commit: ap4y <lod@pisem.net>

    Improve support for the multi-line case statements
---
 swift-mode.el             |  4 ++--
 test/indentation-tests.el | 29 +++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/swift-mode.el b/swift-mode.el
index 04be414..ae06f79 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -260,7 +260,7 @@
    (t (let ((tok (smie-default-forward-token)))
         (cond
          ((equal tok "case")
-          (if (looking-at ".+\\(where.*[,]\\|:\\)")
+          (if (looking-at "\\([\n\t ]\\|.\\)+?\\(where.*[,]\\|:\\)")
               "case"
             "ecase"))
          (t tok))))
@@ -303,7 +303,7 @@
      (t (let ((tok (smie-default-backward-token)))
           (cond
            ((equal tok "case")
-            (if (looking-at ".+\\(where.*[,]\\|:\\)")
+            (if (looking-at "\\([\n\t ]\\|.\\)+?\\(where.*[,]\\|:\\)")
                 "case"
               "ecase"))
            (t tok))))
diff --git a/test/indentation-tests.el b/test/indentation-tests.el
index bbea69c..a395291 100644
--- a/test/indentation-tests.el
+++ b/test/indentation-tests.el
@@ -264,6 +264,35 @@ switch true {
 }
 ")
 
+(check-indentation indents-case-statements-to-same-level-as-enclosing-switch/5
+                   "
+switch {
+    |case foo,
+     bar, buz:
+    foo
+}
+" "
+switch {
+|case foo,
+     bar, buz:
+    foo
+}
+")
+
+(check-indentation indents-case-statements-to-same-level-as-enclosing-switch/6
+                   "
+switch {
+    |case
+    foo, bar, buz:
+    foo
+}
+" "
+switch {
+|case
+    foo, bar, buz:
+    foo
+}
+")
 
 (check-indentation indents-case-statement-bodies/1
 "



reply via email to

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