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

Formatter behavior changes with line comment inside parameter list #1331

Open
lukehutch opened this issue Nov 23, 2023 · 1 comment
Open

Comments

@lukehutch
Copy link

With an inline comment, the last two parameters here get put on the same line, which shouldn't be the case, since the last parameter has a trailing comma:

        await _loadProfileView(
          userId: profileView.userId,
          setLikeActionType: LikeActionType.block,
          // Remove star too from any user that is blocked
          setStarAction: false, onUserActionChanged: widget.onUserActionChanged,
        );

Removing the comment, the last two parameters get put on separate lines, as expected:

        await _loadProfileView(
          userId: profileView.userId,
          setLikeActionType: LikeActionType.block,
          setStarAction: false,
          onUserActionChanged: widget.onUserActionChanged,
        );

Dart version: 3.3.0-91.0.dev

@mraleph mraleph transferred this issue from dart-lang/sdk Nov 24, 2023
@munificent
Copy link
Member

This is working as intended but I'm not sure at all if it's working as desired. When an argument list has a trailing comma, the formatter currently treats it exactly like a collection literal. Collection literals have some special logic where a comment inside the literal triggers a rule where it preserves the newlines and allows multiple elements/arguments on the same line.

That's probably not the most useful behavior for an argument list, though. We're working on a rewrite of the formatter (#1253) which will likely revisit this behavior. In the meantime, if you add a newline yourself between the last two arguments, it will preserve it.

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

No branches or pull requests

2 participants