Skip to content

Commit b06c97b

Browse files
committed
Fix indentation of repeat each
1 parent 12f25fc commit b06c97b

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

swift-mode-lexer.el

+7-1
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ return non-nil."
614614
"isolated" "each"))
615615
(member (swift-mode:token:text next-token)
616616
'("any" "some" "inout" "borrowing" "consuming" "throws"
617-
"rethrows" "in" "where" "isolated")))
617+
"rethrows" "in" "where" "isolated" "each")))
618618
nil)
619619

620620
;; Before async
@@ -731,6 +731,12 @@ return non-nil."
731731
"let" "var" "throw" "import"))
732732
nil)
733733

734+
;; Suppress import semicolon after `repeat' unless followed by a open
735+
;; curly bracket.
736+
((and (equal (swift-mode:token:text previous-token) "repeat")
737+
(not (eq (swift-mode:token:type next-token) '{)))
738+
nil)
739+
734740
;; Inserts implicit semicolon before keywords that starts a new
735741
;; statement.
736742
((member (swift-mode:token:text next-token)

test/swift-files/indent/declarations.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -863,20 +863,20 @@ func foo()
863863

864864

865865
// Value and Type Parameter Packs
866-
// https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md#introduction
866+
// https://github.com/apple/swift-evolution/blob/main/proposals/0393-parameter-packs.md
867867
// https://github.com/apple/swift-evolution/blob/main/proposals/0398-variadic-types.md
868868

869869
func constrain<each S: Sequence>(
870870
_: repeat
871-
each // swift-mode:test:known-bug
872-
S // swift-mode:test:known-bug
871+
each
872+
S
873873
) where (
874874
repeat
875-
( // swift-mode:test:known-bug
875+
(
876876
each
877877
S
878878
)
879-
.Element
879+
.Element
880880
) == (Int, String) {
881881
}
882882

test/swift-files/indent/statements.swift

+20
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,26 @@ for
332332
foo()
333333
}
334334

335+
// Pack iteration
336+
// https://github.com/swiftlang/swift-evolution/blob/main/proposals/0408-pack-iteration.md
337+
for element
338+
in
339+
repeat
340+
each
341+
element {
342+
}
343+
344+
for (left, right)
345+
in
346+
repeat
347+
(
348+
each
349+
lhs,
350+
each
351+
rhs
352+
) {
353+
}
354+
335355

336356
// While statements
337357

0 commit comments

Comments
 (0)