Skip to content

Add breaks around conditions of while-stmt. #184

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

Merged
merged 1 commit into from
Apr 8, 2020

Conversation

dylansturg
Copy link
Contributor

This aligns the behavior of while-stmt and guard-stmt conditions. The while-stmt conditions didn't have open-breaks, which meant there was no additional indentation nor would continuation breaks be able to stack.

This means there's always a break before the first token of the condition element list when the while-stmt's condition is multiple lines. That is likely to cause some churn in existing code. An alternative would be to treat this like if-stmt, where there is no break after the while token.

Issues

  • This is likely to cause churn. I think we could minimize that by aligning with the if-stmt behavior, but I think it makes more sense to allow a break after while, like guard.

@allevato
Copy link
Member

allevato commented Apr 8, 2020

To avoid churn, can we align with if for now, then once we have region-restricted formatting in the future, change it to have the break after the while?

This aligns the behavior of while-stmt and if-stmt conditions. The while-stmt conditions didn't have open-breaks, which meant there was no additional indentation nor would continuation breaks be able to stack.

This can result in exceeding the max line length if a while-stmt has a label and first condition, up to its first break, that exceeds the remaining line length.
@dylansturg dylansturg force-pushed the while_not_indenting branch from fba8314 to f437f71 Compare April 8, 2020 20:40
@dylansturg
Copy link
Contributor Author

To avoid churn, can we align with if for now, then once we have region-restricted formatting in the future, change it to have the break after the while?

I think that's fair. Made the change.

@allevato allevato merged commit cd6ae7c into swiftlang:master Apr 8, 2020
@dylansturg dylansturg deleted the while_not_indenting branch April 15, 2020 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants