Skip to content

Commit a84f5c8

Browse files
committed
1 parent 286b46e commit a84f5c8

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed

swift-mode-indent.el

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,10 +1137,19 @@ comma at eol."
11371137
;; , E
11381138
;; , F
11391139
;; }
1140+
;;
1141+
;; https://github.com/apple/swift-evolution/blob/master/proposals/0276-multi-pattern-catch-clauses.md
1142+
;; do {
1143+
;; } catch Foo(let a),
1144+
;; Bar(let a) {
1145+
;; foo(a)
1146+
;; }
11401147
(let ((pos (point))
11411148
(parent (swift-mode:backward-sexps-until
11421149
;; Includes "if" to stop at the last else-if.
1143-
(append swift-mode:statement-parent-tokens '("if" \( \[ <))
1150+
;; Includes "catch" to stop at the last catch.
1151+
(append swift-mode:statement-parent-tokens
1152+
'("if" "catch" \( \[ <))
11441153
(if utrecht-style nil '(\,))
11451154
(if utrecht-style '(\,) nil))))
11461155
(cond
@@ -1151,7 +1160,7 @@ comma at eol."
11511160
(goto-char pos)
11521161
(swift-mode:backward-sexps-until '(< "where")))
11531162

1154-
((equal (swift-mode:token:text parent) "if")
1163+
((member (swift-mode:token:text parent) '("if" "catch"))
11551164
parent)
11561165

11571166
(t

test/swift-files/indent/statements.swift

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,50 @@ catch
10411041
foo()
10421042
}
10431043

1044+
// Multi-Pattern Catch Clauses
1045+
// https://github.com/apple/swift-evolution/blob/master/proposals/0276-multi-pattern-catch-clauses.md
1046+
1047+
do {
1048+
} catch Foo(let a)
1049+
where
1050+
foo
1051+
.bar(),
1052+
Bar(let a)
1053+
where
1054+
foo
1055+
.bar(),
1056+
Baz(let a) where
1057+
foo
1058+
.bar() {
1059+
foo(a)
1060+
} catch Foo(let a)
1061+
where
1062+
foo
1063+
.bar()
1064+
, Bar(let a)
1065+
where
1066+
foo
1067+
.bar()
1068+
, Baz(let a) where
1069+
foo
1070+
.bar() {
1071+
foo(a)
1072+
} catch
1073+
Foo(let a)
1074+
where
1075+
foo
1076+
.bar(),
1077+
Bar(let a)
1078+
where
1079+
foo
1080+
.bar(),
1081+
Baz(let a) where
1082+
foo
1083+
.bar() {
1084+
foo(a)
1085+
}
1086+
1087+
10441088
// Conditional control statements
10451089

10461090
func foo() {

0 commit comments

Comments
 (0)