branch: elpa/swift-mode
commit aa49efad76b4a72c0cb6c6a661863eec48aef872
Author: taku0 <[email protected]>
Commit: taku0 <[email protected]>
Fix indentation of switch.
---
swift-mode-lexer.el | 6 +++++-
test/swift-files/statements.swift | 7 +++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/swift-mode-lexer.el b/swift-mode-lexer.el
index 97cabb7..4224f1e 100644
--- a/swift-mode-lexer.el
+++ b/swift-mode-lexer.el
@@ -258,7 +258,7 @@ END is the point after the token."
;; Suppress implicit semicolon after keywords that cannot end statements.
((member (swift-mode:token:text previous-token)
'("while" "for" "switch" "case" "default" "catch" "if" "guard"
- "let" "var" "throw" "import" "return"))
+ "let" "var" "throw" "import"))
nil)
;; Inserts implicit semicolon before keywords that starts a new
@@ -268,6 +268,10 @@ END is the point after the token."
"guard" "let" "var" "throw" "import" "return"))
t)
+ ;; Suppress implicit semicolon after return.
+ ((equal (swift-mode:token:text previous-token) "return")
+ nil)
+
;; Inserts implicit semicolon before `while' unless it is part of
;; `repeat...while'.
((equal (swift-mode:token:text next-token) "while")
diff --git a/test/swift-files/statements.swift
b/test/swift-files/statements.swift
index 79947ad..f46cd24 100644
--- a/test/swift-files/statements.swift
+++ b/test/swift-files/statements.swift
@@ -897,6 +897,13 @@ default:
}
}
+switch foo {
+case 1:
+ return
+case 2:
+ bar()
+}
+
// swift-mode:test:eval (setq-local swift-mode:switch-case-offset 2)
switch foo {