Skip to content

Restore some discretionary newlines from PR #143 #158

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

Conversation

dylansturg
Copy link
Contributor

Several breaks were changed to disallow discretionary newlines in #143. In practice, some of these breaks actually require a more nuanced approach because grouping around the content after the : is frequently subjective. Depending on the length of the label/key before the : and the actual expr or type, it varies whether a group should be around the content after the :. The formatter's current model doesn't support modifying the tokens to add/remove group tokens once the token stream is created.

In a future patch, it would be nice to have a way to switch between grouping and not grouping the content after the : based on the preceding key or label.

Reverted ignoresDiscretionary breaks include after the colon in...

  • a dictionary type
  • a dictionary element
  • a function call argument
  • a function decl parameter
  • a generic parameter
  • a tuple type
  • a tuple expr element

Several breaks were changed to disallow discretionary newlines in swiftlang#143. In practice, some of these breaks actually require a more nuanced approach because grouping around the content after the `:` is frequently subjective. Depending on the length of the label/key before the `:` and the actual expr or type, it varies whether a group should be around the content after the `:`. The formatter's current model doesn't support modifying the tokens to add/remove group tokens once the token stream is created.

In a future patch, it would be nice to have a way to switch between grouping and not grouping the content after the `:` based on the preceding key or label.

Reverted `ignoresDiscretionary` breaks include after the colon in...
- a dictionary type
- a dictionary element
- a function call argument
- a function decl parameter
- a generic parameter
- a tuple type
- a tuple expr element
@allevato allevato merged commit 70c38a2 into swiftlang:master Mar 10, 2020
@dylansturg dylansturg deleted the experimental_remove_ignores_discretionary branch March 10, 2020 17:24
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