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

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

[nongnu] elpa/swift-mode f42752b 223/496: Respect comments when calculat


From: ELPA Syncer
Subject: [nongnu] elpa/swift-mode f42752b 223/496: Respect comments when calculating position of the implicit semicolon
Date: Sun, 29 Aug 2021 11:33:40 -0400 (EDT)

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

    Respect comments when calculating position of the implicit semicolon
---
 swift-mode.el             |  6 ++++--
 test/indentation-tests.el | 26 ++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/swift-mode.el b/swift-mode.el
index 786763c..91e0f0d 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -224,15 +224,17 @@
              ;; Characters placed on the second line in multi-line expression
              (looking-at "[ \n\t]+[.?:]")
              ;; Operators placed on the second line in multi-line expression
-             (looking-at (concat "[ \n\t]+" swift-smie--operators-regexp))
+             ;; Should respect here possible comments strict before the 
linebreak
+             (looking-at (concat "\\(\/\/.*\\)?\n[[:space:]]*" 
swift-smie--operators-regexp))
              (and (looking-back swift-smie--operators-regexp (- (point) 3) t)
                   ;; Not a generic type
                   (not (looking-back "[[:upper:]]>" (- (point) 2) t)))
              ))))
 
 (defun swift-smie--forward-token ()
+  (skip-chars-forward " \t")
   (cond
-   ((and (looking-at "\n") (swift-smie--implicit-semi-p))
+   ((and (looking-at "\n\\|\/\/") (swift-smie--implicit-semi-p))
     (if (eolp) (forward-char 1) (forward-comment 1))
     ";")
 
diff --git a/test/indentation-tests.el b/test/indentation-tests.el
index b5fa50e..f3cbff4 100644
--- a/test/indentation-tests.el
+++ b/test/indentation-tests.el
@@ -1955,6 +1955,32 @@ var object: JsonObject<Foo>!
 |var object: JsonObject
 ")
 
+(check-indentation indents-expression-with-comment/1
+                   "
+func foo() {
+    foo() // foo
+       |foo()
+}
+" "
+func foo() {
+    foo() // foo
+    |foo()
+}
+")
+
+(check-indentation indents-expression-with-comment/2
+                   "
+func foo() {
+    let x = 1 // foo
+    |/ 1
+}
+" "
+func foo() {
+    let x = 1 // foo
+            |/ 1
+}
+")
+
 (provide 'indentation-tests)
 
 ;;; indentation-tests.el ends here



reply via email to

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