branch: elpa/swift-mode
commit b06c97b909418b5dca3d15351b2ce86a04df32fb
Author: taku0 <[email protected]>
Commit: taku0 <[email protected]>
Fix indentation of `repeat each`
---
swift-mode-lexer.el | 8 +++++++-
test/swift-files/indent/declarations.swift | 10 +++++-----
test/swift-files/indent/statements.swift | 20 ++++++++++++++++++++
3 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/swift-mode-lexer.el b/swift-mode-lexer.el
index d82c3813c1..68b6055ff4 100644
--- a/swift-mode-lexer.el
+++ b/swift-mode-lexer.el
@@ -614,7 +614,7 @@ return non-nil."
"isolated" "each"))
(member (swift-mode:token:text next-token)
'("any" "some" "inout" "borrowing" "consuming" "throws"
- "rethrows" "in" "where" "isolated")))
+ "rethrows" "in" "where" "isolated" "each")))
nil)
;; Before async
@@ -731,6 +731,12 @@ return non-nil."
"let" "var" "throw" "import"))
nil)
+ ;; Suppress import semicolon after `repeat' unless followed by a open
+ ;; curly bracket.
+ ((and (equal (swift-mode:token:text previous-token) "repeat")
+ (not (eq (swift-mode:token:type next-token) '{)))
+ nil)
+
;; Inserts implicit semicolon before keywords that starts a new
;; statement.
((member (swift-mode:token:text next-token)
diff --git a/test/swift-files/indent/declarations.swift
b/test/swift-files/indent/declarations.swift
index 266d9cc782..5306a5f314 100644
--- a/test/swift-files/indent/declarations.swift
+++ b/test/swift-files/indent/declarations.swift
@@ -863,20 +863,20 @@ func foo()
// Value and Type Parameter Packs
-//
https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md#introduction
+//
https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md
//
https://github.com/apple/swift-evolution/blob/main/proposals/0398-variadic-types.md
func constrain<each S: Sequence>(
_: repeat
- each // swift-mode:test:known-bug
- S // swift-mode:test:known-bug
+ each
+ S
) where (
repeat
- ( // swift-mode:test:known-bug
+ (
each
S
)
- .Element
+ .Element
) == (Int, String) {
}
diff --git a/test/swift-files/indent/statements.swift
b/test/swift-files/indent/statements.swift
index 45ada271f0..19f8a1b919 100644
--- a/test/swift-files/indent/statements.swift
+++ b/test/swift-files/indent/statements.swift
@@ -332,6 +332,26 @@ for
foo()
}
+// Pack iteration
+//
https://github.com/swiftlang/swift-evolution/blob/main/proposals/0408-pack-iteration.md
+for element
+ in
+ repeat
+ each
+ element {
+}
+
+for (left, right)
+ in
+ repeat
+ (
+ each
+ lhs,
+ each
+ rhs
+ ) {
+}
+
// While statements