branch: elpa/swift-mode commit a1d7a06d251e2a0ac930bc0c3118d977f2838a1c Merge: e898e7e 4289bd7 Author: Arthur Evstifeev <m...@ap4y.me> Commit: Arthur Evstifeev <m...@ap4y.me>
Merge pull request #88 from uk-ar/fix-indent-after-comment Fix indent when after comment --- swift-mode.el | 5 ++++- test/indentation-tests.el | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/swift-mode.el b/swift-mode.el index 586ef5c..3c506b4 100644 --- a/swift-mode.el +++ b/swift-mode.el @@ -227,7 +227,10 @@ (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)) + (save-excursion + (forward-comment (buffer-size)) + (looking-at 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))) diff --git a/test/indentation-tests.el b/test/indentation-tests.el index 20367de..256f3d7 100644 --- a/test/indentation-tests.el +++ b/test/indentation-tests.el @@ -2050,6 +2050,21 @@ func foo() { } ") +(check-indentation indents-expression-with-comment/3 + " +func foo() { + foo() + // + |foo() +} +" " +func foo() { + foo() + // + |foo() +} +") + (provide 'indentation-tests) ;;; indentation-tests.el ends here