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

Improve string reflowing #35

Merged
merged 5 commits into from
Oct 18, 2019
Merged

Improve string reflowing #35

merged 5 commits into from
Oct 18, 2019

Conversation

dansanduleac
Copy link
Contributor

Before this PR

There was a hack in Level#computeBreaks to make StringWrapper and our "no newline after assignments heuristic" (802a186) work together.

/**
* Trick to cooperate with StringWrapper. If the value is a single element (e.g. a String), then allow it to stay on
* this line, and rely on the StringWrapper to break it accordingly.
*
* <p>This is to prevent StringWrapperIntegrationTest#idemponent from breaking.
*/
private boolean isSingleString() {
return !this.docs.stream().anyMatch(doc -> doc instanceof Level)
&& this.docs.stream().filter(doc -> doc instanceof Break).count() == 1
&& getFlat().startsWith(" \"");
}

However, this relies on leaving a string on the assignment line, and the StringWrapper actually being able to split it, which might not be the case (if it has no whitespace, for instance). Here's an example where it failed in this way (file view)

After this PR

==COMMIT_MSG==
Reflow long strings more thoroughly, taking into account that once a string is broken, its first chunk might fit on the starting line and thus it needs to be reflowed again.
==COMMIT_MSG==

Possible downsides?

@changelog-app
Copy link

changelog-app bot commented Oct 17, 2019

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Reflow long strings more thoroughly, taking into account that once a string is broken, its first chunk might fit on the starting line and thus it needs to be reflowed again.

Check the box to generate changelog(s)

  • Generate changelog entry

@iamdanfox iamdanfox merged commit 009154c into develop Oct 18, 2019
@svc-autorelease
Copy link
Collaborator

Released 0.2.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants