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

Fix possible exception with initializer body close to column limit #257

Merged
merged 6 commits into from
Mar 30, 2020

Conversation

dansanduleac
Copy link
Contributor

Before this PR

When formatting far-off (close to 120 characters) lambda or assignment body, the formatting code could throw an exception.
This would happen if the body contained an empty level, such as the case when e.g. doing new SomeClass<>(): there is an empty level created for the type arguments inside <>, but it's empty because there are no type arguments.

This would throw off the logic that decides whether trying to put such body onto the next line results in it taking only one line (in handle_breakOnlyIfInnerLevelsThenFitOnOneLine).
It could first infer that the empty level was broken (marked as such because the column would have already exceeded 120 columns), but then later down the line tryInlinePrefixOntoCurrentLine would try to find this broken level, only this time it would filter out empty levels, and so never find that level and throw.

After this PR

==COMMIT_MSG==
Fix edge case with empty levels causing formattings very close to the column limit to throw.
==COMMIT_MSG==

Possible downsides?

@changelog-app
Copy link

changelog-app bot commented Mar 30, 2020

Generate changelog in changelog/@unreleased

Type

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

Description

Fix edge case with empty levels causing formattings very close to the column limit to throw.

Check the box to generate changelog(s)

  • Generate changelog entry

@policy-bot policy-bot bot requested a review from CRogers March 30, 2020 16:07
Copy link
Contributor

@carterkozak carterkozak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Dan!

@bulldozer-bot bulldozer-bot bot merged commit 438feb7 into develop Mar 30, 2020
@bulldozer-bot bulldozer-bot bot deleted the ds/fix-far-lambda-fail branch March 30, 2020 16:46
@svc-autorelease
Copy link
Collaborator

Released 0.3.28

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