-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SourceKit/CodeFormat] Column-align multiple patterns in catch clauses #30870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SourceKit/CodeFormat] Column-align multiple patterns in catch clauses #30870
Conversation
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating this, the approach LGTM!
test/swift-indent/basic.swift
Outdated
{ | ||
print("hello") | ||
} | ||
catch MyErr.a(let code. let message), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
catch MyErr.a(let code. let message), | |
catch MyErr.a(let code, let message), |
lib/IDE/Formatting.cpp
Outdated
if (!Elem.getPattern() || Elem.getPattern()->isImplicit()) | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this indent something like the following correctly?
do {
throw MyErr.a
} catch where foo == 0,
where bar == 1 {
}
I don't think anyone will be writing code like this in practice, but it is allowed and may be worth testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I'll fix it and add it to the test cases.
Catch clauses now support mutliple patterns. Like 'case' patterns, these should be column-aligned if split across multiple lines. do { ... } catch MyErr.a(let x), MyErr.b(let x) { print("hello") }
592d629
to
19d6eff
Compare
@swift-ci please test |
Build failed |
Build failed |
catch
clauses now support multiple patterns thanks to #27776. Likecase
patterns, these should be column-aligned if split across multiple lines like below:Resolves rdar://problem/61614223