Skip to content
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

[SR-12844] Scope-based indentation for if/guard/etc #325

Open
swift-ci opened this issue May 20, 2020 · 0 comments
Open

[SR-12844] Scope-based indentation for if/guard/etc #325

swift-ci opened this issue May 20, 2020 · 0 comments

Comments

@swift-ci
Copy link

Previous ID SR-12844
Radar None
Original Reporter freak4pc (JIRA User)
Type New Feature
Additional Detail from JIRA
Votes 0
Component/s swift-format
Labels New Feature
Assignee None
Priority Medium

md5: 52ad6d881cad12a71f7111c93476b884

is duplicated by:

  • SR-13187 swift-format formats multiline pattern binding strangely

Issue Description:

Today, both Xcode and swift-format perform the following sort of indentation on multi-line guards and ifs:

guard let thing1 = someThing,
    let thing2 = someThing else {
        // Some indented code
}

This feels extremely asymmetrical and unaesthetic. What would be preferable is formatting this way (or providing a way to do so):

guard let thing1 = someThing,
      let thing2 = someThing else {
    // Some indented code
}

This indents the body of the guard 4-spaces (or whatever is defined) away from the scope itself (the guard) and not the last line which might not be the scope. Also it aligns the different conditions which make up the conditional.

Is that achievable with swift-format? Is there a way to make it easily achievable?

Thank you 🙂

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant