branch: elpa/swift-mode
commit a2f5b33e438394a8d9a292be94ffe71bf50417e4
Author: uk-ar <yuuki....@gmail.com>
Commit: uk-ar <yuuki....@gmail.com>

    Fix indent when operator hanging after comment
---
 swift-mode.el             |  4 +++-
 test/indentation-tests.el | 17 ++++++++++++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/swift-mode.el b/swift-mode.el
index 364cb89..586ef5c 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -222,7 +222,9 @@
              ;; "in" operator in closure
              (looking-back "in" (- (point) 2) t)
              ;; Characters placed on the second line in multi-line expression
-             (looking-at "[ \n\t]+[.?:]")
+             (save-excursion
+               (forward-comment (buffer-size))
+               (looking-at "[.?:]"))
              ;; Operators placed on the second line in multi-line expression
              ;; Should respect here possible comments strict before the 
linebreak
              (looking-at (concat "\\(\/\/.*\\)?\n[[:space:]]*" 
swift-smie--operators-regexp))
diff --git a/test/indentation-tests.el b/test/indentation-tests.el
index e621d8c..20367de 100644
--- a/test/indentation-tests.el
+++ b/test/indentation-tests.el
@@ -1607,6 +1607,21 @@ let a = a ?
 
 (check-indentation conditional-operator/8
                    "
+let a = a //foo
+        |? a +
+          1
+        : a +
+          1
+" "
+let a = a //foo
+        |? a +
+          1
+        : a +
+          1
+")
+
+(check-indentation conditional-operator/9
+                   "
 func foo() {
     return order!.deliver ?
          |OrderViewTableDeliveryCells.lastCellIndex.rawValue :
@@ -1620,7 +1635,7 @@ func foo() {
 }
 ")
 
-(check-indentation conditional-operator/9
+(check-indentation conditional-operator/10
                    "
 func foo() {
     return order!.deliver ?

Reply via email to