Skip to content

Conversation

@munificent
Copy link
Member

I was trying out the new formatter on a corpus after #1687 and saw a bunch of diffs like:

// Before:
Widget(
  name:
      some.property.chain,
)

// After:
Widget(
  name: some
      .property
      .chain,
)

While the new headline style looks nice for most method call chains, it looks weird if it's only just a series of properties. In particular, a single foo.bar looks really silly when split.

This PR bumps the split cost of a chain up if it only contains properties. That leads the solver to prefer splitting the surrounding construct when possible.

I was trying out the new formatter on a corpus after #1687 and saw a bunch of diffs like:

```dart
// Before:
Widget(
  name:
      some.property.chain,
)

// After:
Widget(
  name: some
      .property
      .chain,
)
```

While the new headline style looks nice for most method call chains, it looks weird if it's only just a series of properties. In particular, a single `foo.bar` looks really silly when split.

This PR bumps the split cost of a chain up if it only contains properties. That leads the solver to prefer splitting the surrounding construct when possible.
@munificent munificent merged commit d8eb9c9 into main Apr 1, 2025
7 checks passed
@munificent munificent deleted the avoid-splitting-properties branch April 1, 2025 00:39
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.

3 participants