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

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

[nongnu] elpa/swift-mode 5fabebd 196/496: Improve indentation rules for


From: ELPA Syncer
Subject: [nongnu] elpa/swift-mode 5fabebd 196/496: Improve indentation rules for function arguments
Date: Sun, 29 Aug 2021 11:33:35 -0400 (EDT)

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

    Improve indentation rules for function arguments
---
 swift-mode.el             | 11 ++++++-----
 test/indentation-tests.el | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/swift-mode.el b/swift-mode.el
index fa8a8a9..8238521 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -344,17 +344,18 @@
              swift-indent-offset
            (smie-rule-parent))))
 
+    (`(:after . "(") (smie-rule-parent swift-indent-offset))
     (`(:before . "(")
-     (if (smie-rule-next-p "[") (smie-rule-parent)))
+     (cond
+      ((smie-rule-next-p "[") (smie-rule-parent))
+      ((smie-rule-parent-p ".") 0)))
+
     (`(:before . "[")
      (cond
       ((smie-rule-prev-p "->") swift-indent-offset)
       ((smie-rule-parent-p "[") swift-indent-offset)
       (t (smie-rule-parent))))
-    (`(:after . "->") swift-indent-offset)
-
-    ;; Normalize behaviour with and without declaration specifier
-    (`(:before . "DECSPEC") swift-indent-offset)
+    (`(:after . "->") (smie-rule-parent swift-indent-offset))
     ))
 
 ;;; Font lock
diff --git a/test/indentation-tests.el b/test/indentation-tests.el
index 03cbdd5..e3f91e7 100644
--- a/test/indentation-tests.el
+++ b/test/indentation-tests.el
@@ -1037,6 +1037,39 @@ let options = NSRegularExpressionOptions.CaseInsensitive 
&
               |NSRegularExpressionOptions.DotMatchesLineSeparators
 ")
 
+
+(check-indentation indents-long-parameters/1
+                   "
+func foo() {
+    timer = NSTimer.scheduledTimerWithTimeInterval(
+            |1.0,
+                target: self,
+                selector: Selector(\"onTimer\"),
+                userInfo: nil,
+                repeats: true)
+}
+" "
+func foo() {
+    timer = NSTimer.scheduledTimerWithTimeInterval(
+                |1.0,
+                target: self,
+                selector: Selector(\"onTimer\"),
+                userInfo: nil,
+                repeats: true)
+}
+")
+
+(check-indentation indents-long-parameters/2
+                   "
+aaaaaa.aaaaaaaaaaaaaaaaaaaaa(
+  |aaaaaaaaaaaaaaaaaaaaa
+)
+" "
+aaaaaa.aaaaaaaaaaaaaaaaaaaaa(
+    |aaaaaaaaaaaaaaaaaaaaa
+)
+")
+
 (check-indentation indents-multiline-expressions-to-user-defined-offset/1
                    "
 NSNotificationCenter.defaultCenter().



reply via email to

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