branch: elpa/swift-mode commit c2c3c01155f138eb1334698fbecb5af392c6a50e Author: ap4y <l...@pisem.net> Commit: ap4y <l...@pisem.net>
Improve support for optional types --- swift-mode.el | 9 ++++++++- test/indentation-tests.el | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/swift-mode.el b/swift-mode.el index 4640a56..8b68c54 100644 --- a/swift-mode.el +++ b/swift-mode.el @@ -210,7 +210,14 @@ (defun swift-smie--implicit-semi-p () (save-excursion - (not (or (memq (char-before) '(?\{ ?\[ ?, ?. ?\? ?: ?= ?\()) + (not (or (memq (char-before) '(?\{ ?\[ ?, ?. ?: ?= ?\()) + ;; Checking for operators form for "?" and "!", + ;; they can be a part of the type. + ;; Special case: is? and as? are operators. + (looking-back "[[:space:]][?!]" (- (point) 2) t) + ;; is? and as? are operators + (looking-back "as[?]\\|is[?]" (- (point) 3) t) + ;; Leding character in multi-line expression (looking-at "[ \n\t]+[.?:]") (and (looking-back swift-smie--operators-regexp (- (point) 3) t) ;; Not a generic type diff --git a/test/indentation-tests.el b/test/indentation-tests.el index 1a9af87..f048d14 100644 --- a/test/indentation-tests.el +++ b/test/indentation-tests.el @@ -1349,6 +1349,15 @@ UIView.animateWithDuration( |}) ") +(check-indentation indents-expression-with-optional-type/1 + " +var object: JsonObject? + |var object: JsonObject +" " +var object: JsonObject? +|var object: JsonObject +") + (provide 'indentation-tests) ;;; indentation-tests.el ends here