branch: elpa/swift-mode commit 8889a6a374f9776a756f655cfa6d3771649722dd Merge: add2ae9 3931734 Author: Arthur Evstifeev <m...@ap4y.me> Commit: Arthur Evstifeev <m...@ap4y.me>
Merge pull request #112 from uk-ar/fix-multiline-expressions fix multi-line expressions --- swift-mode.el | 10 +++++----- test/indentation-tests.el | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/swift-mode.el b/swift-mode.el index 9b74ae8..2de187e 100644 --- a/swift-mode.el +++ b/swift-mode.el @@ -408,13 +408,13 @@ We try to constraint those lookups by reasonable number of lines.") ;; Apply swift-indent-multiline-statement-offset if ;; operator is the last symbol on the line - (`(:before . ,(pred (lambda (token) + (`(:after . ,(pred (lambda (token) (member token swift-smie--operators)))) (when (and (smie-rule-hanging-p) - (not (apply 'smie-rule-parent-p swift-smie--operators))) - (if (smie-rule-parent-p "{") - (+ swift-indent-offset swift-indent-multiline-statement-offset) - swift-indent-multiline-statement-offset))) + (not (apply 'smie-rule-parent-p + (append swift-smie--operators '("?" ":" "="))))) + swift-indent-multiline-statement-offset + )) (`(:before . ",") (if (and swift-indent-hanging-comma-offset (smie-rule-parent-p "class" "case")) diff --git a/test/indentation-tests.el b/test/indentation-tests.el index 4e01ab0..c77666b 100644 --- a/test/indentation-tests.el +++ b/test/indentation-tests.el @@ -1508,6 +1508,19 @@ let x = bar |defaultValue ") +(check-indentation indents-multiline-expressions/24 + " +let foo = + bar + + |baz + + a +" " +let foo = + bar + + |baz + + a +") + (check-indentation indents-long-parameters/1 " func foo() { @@ -1619,7 +1632,7 @@ let options = NSRegularExpressionOptions.CaseInsensitive & |NSRegularExpressionOptions.DotMatchesLineSeparators " " let options = NSRegularExpressionOptions.CaseInsensitive & - |NSRegularExpressionOptions.DotMatchesLineSeparators + |NSRegularExpressionOptions.DotMatchesLineSeparators " ((swift-indent-multiline-statement-offset 4)))