branch: elpa/swift-mode commit 0cab4b2c4b6db68e7f5fb6ee83cacda66da4c4e0 Author: taku0 <mxxouy6x3m_git...@tatapa.org> Commit: taku0 <mxxouy6x3m_git...@tatapa.org>
Fix indentation for catch blocks without patterns Fixes #138. ``` do { } catch { } ``` --- swift-mode-lexer.el | 26 +++++++++++++------------- test/swift-files/statements.swift | 6 +++++- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/swift-mode-lexer.el b/swift-mode-lexer.el index 0f6cee0..78dace9 100644 --- a/swift-mode-lexer.el +++ b/swift-mode-lexer.el @@ -194,6 +194,19 @@ END is the point after the token." '("inout" "throws" "rethrows" "in" "where"))) nil) + ;; Inserts semicolon before open curly bracket. + ;; + ;; Open curly bracket may continue the previous line, but we do not indent + ;; there. For example, the code below is parsed as `(foo() { x in ... })' + ;; by the Swift compiler, but we indent it like `foo(); { x in ... }'. + ;; + ;; foo() + ;; { // does not indent here + ;; x in + ;; ... + ;; } + ((eq (swift-mode:token:type next-token) '\{) t) + ;; Inserts implicit semicolon around #... directives. ;; ;; Note that we cannot split #if line; the following code is not allowed. @@ -330,19 +343,6 @@ END is the point after the token." (swift-mode:forward-token-simple))) "<"))) - ;; Inserts semicolon before open curly bracket. - ;; - ;; Open curly bracket may continue the previous line, but we do not indent - ;; there. For example, the code below is parsed as `(foo() { x in ... })' - ;; by the Swift compiler, but we indent it like `foo(); { x in ... }'. - ;; - ;; foo() - ;; { // does not indent here - ;; x in - ;; ... - ;; } - ((eq (swift-mode:token:type next-token) '\{) t) - ;; Suppress implicit semicolon after keywords that behave like method ;; names. ;; diff --git a/test/swift-files/statements.swift b/test/swift-files/statements.swift index 9146fa8..308c110 100644 --- a/test/swift-files/statements.swift +++ b/test/swift-files/statements.swift @@ -1035,7 +1035,11 @@ catch foo() foo() } - +catch +{ + foo() + foo() +} // Conditional control statements