branch: elpa/swift-mode
commit d0c65bc50dc45b3031e216aa4352899b8f05a844
Author: ap4y <[email protected]>
Commit: ap4y <[email protected]>
Fix bug with the closing parentheses in method calls and function
declarations with multi-line arguments
---
swift-mode.el | 6 +++---
test/indentation-tests.el | 23 +++++++++++++++++++++++
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/swift-mode.el b/swift-mode.el
index 6d6776c..9e4408f 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -366,10 +366,12 @@
(`(:after . ,(or `"func" `"class")) (smie-rule-parent 0))
(`(:after . "(") (smie-rule-parent swift-indent-offset))
+
(`(:before . "(")
(cond
((smie-rule-next-p "[") (smie-rule-parent))
- ((smie-rule-parent-p ".") 0)))
+ ;; Custom indentation for method arguments
+ ((smie-rule-parent-p "." "func") (smie-rule-parent 0))))
(`(:before . "[")
(cond
@@ -377,8 +379,6 @@
((smie-rule-parent-p "[") swift-indent-offset)
(t (smie-rule-parent))))
(`(:after . "->") (smie-rule-parent swift-indent-offset))
-
- (`(:close-all . "}") (if (smie-rule-parent-p "(") 't))
))
;;; Font lock
diff --git a/test/indentation-tests.el b/test/indentation-tests.el
index 56ffafd..d3ec032 100644
--- a/test/indentation-tests.el
+++ b/test/indentation-tests.el
@@ -1262,6 +1262,29 @@ func a(
}
")
+(check-indentation indents-long-parameters/5
+ "
+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-multiline-expressions-to-user-defined-offset/1
"
NSNotificationCenter.defaultCenter()