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

Further improve multiline string formatting. #534

Merged
merged 1 commit into from
May 27, 2023

Conversation

allevato
Copy link
Member

These changes remove unnecessary grouping around multiline string literals that were forcing subexpressions to wrap in less than ideal ways. Since multiline strings force hard line breaks after the open quotes, we can remove the grouping and produce better results when complex expressions are involved. For example,

let x = """
  abc
  def
  """ + """
    ghi
    jkl
    """

Before this change, we were forcing breaks after the = and before the +. Now, we only do so if the open quotes would overflow the line.

These changes remove unnecessary grouping around multiline string
literals that were forcing subexpressions to wrap in less than
ideal ways. Since multiline strings force hard line breaks after
the open quotes, we can remove the grouping and produce better
results when complex expressions are involved. For example,

```swift
let x = """
  abc
  def
  """ + """
    ghi
    jkl
    """
```

Before this change, we were forcing breaks after the `=` and
before the `+`. Now, we only do so if the open quotes would
overflow the line.
@allevato
Copy link
Member Author

cc @dylansturg

@allevato allevato merged commit 799c88b into swiftlang:main May 27, 2023
@allevato allevato deleted the more-multiline-string-fixes branch May 27, 2023 15:57
allevato added a commit to allevato/swift-format that referenced this pull request Jun 29, 2023
…fixes

Further improve multiline string formatting.
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.

None yet

2 participants