Skip to content

Commit d8f04a9

Browse files
authored
Update TODO comment on for-in to consider how "in" should split. (#1355)
In the old and new style, if a newline occurs in the pattern of an if-case statement or element, it forces a split before the `case` too. That syntax is structurally similar to for-in loops, but for-in loops currently don't force that split. (And I had to add explicit support to *not* force a split there.) Update the TODO comment to consider whether we want to make for-in loops format similar to if-case.
1 parent 295e4c5 commit d8f04a9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/src/front_end/piece_factory.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,11 @@ mixin PieceFactory {
330330
// }
331331
//
332332
// Currently, the formatter prefers 1 over 3. We may want to revisit
333-
// that and prefer 3 instead.
333+
// that and prefer 3 instead. Or perhaps we shouldn't pass
334+
// `allowInnerSplit: true` and force the `in` to split if the
335+
// initializer does. That would be consistent with how we handle
336+
// splitting before `case` when the pattern has a newline in an if-case
337+
// statement or element.
334338
return buildPiece((b) {
335339
b.token(leftParenthesis);
336340
b.add(createAssignment(

0 commit comments

Comments
 (0)