branch: elpa/swift-mode
commit 67fd6a9ada58f33c87445901561ad2e7fd475ecf
Author: Christian Kruse <[email protected]>
Commit: Christian Kruse <[email protected]>
Fix indentation of multiline operator expressions
Expressions with multiple operators over multiple lines got indented one
offset deeper per line break. An additional smie check for being a
sibling should fix this problem.
---
swift-mode.el | 3 ++-
test/indentation-tests.el | 13 +++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/swift-mode.el b/swift-mode.el
index 449d134..2602d26 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -286,7 +286,8 @@
;; Apply swift-indent-multiline-statement-offset if
;; operator is the last symbol on the line
(`(:before . "OP")
- (if (looking-at ".[\n]")
+ (if (and (looking-at ".[\n]")
+ (not (smie-rule-sibling-p)))
(smie-rule-parent swift-indent-multiline-statement-offset)))
;; Indent second line of the multi-line class
diff --git a/test/indentation-tests.el b/test/indentation-tests.el
index 1c4b1fb..cb810b1 100644
--- a/test/indentation-tests.el
+++ b/test/indentation-tests.el
@@ -919,6 +919,19 @@ let foo = bar >
|baz
")
+(check-indentation indents-multiline-operators-only-once
+ "
+1 +
+ 2 + 5 *
+|3
+" "
+1 +
+ 2 + 5 *
+ |3
+"
+)
+
+
(provide 'indentation-tests)
;;; indentation-tests.el ends here