Skip to content

Commit

Permalink
State: don't waive comment overflow for binPack
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Dec 25, 2021
1 parent f683e3d commit e8ebc3c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,15 @@ final case class State(
else
(style.comments.wrap eq Comments.Wrap.trailing) ||
style.comments.willWrap && nextSplit.isNL
}
} && (nextSplit.isNL || {
// do not waive overflow in binpacking case
val owner = tok.meta.rightOwner
val ownerLast = tokens.getLastNonTrivial(owner).left
val isBracket = ownerLast.is[Token.RightBracket]
!(isBracket || ownerLast.is[Token.RightParen]) ||
style.binPack.defnSite(isBracket).isNever && isDefnSite(owner) ||
style.binPack.callSite(isBracket).isNever && isCallSite(owner)
})
}
) {
(math.max(0, delayedPenalty), 0) // fits inside column
Expand Down
40 changes: 20 additions & 20 deletions scalafmt-tests/src/test/resources/unit/Comment.stat
Original file line number Diff line number Diff line change
Expand Up @@ -519,16 +519,16 @@ object a {
}
>>>
object a {
val requestedIds = Seq( /* First 2 will not be taken into account since this app for 'Do Not Sell'
* and 'ATT' only */
CcpaRequestIds("luid", "1", None, date, version, RequestType.Delete),
CcpaRequestIds("hemlmd5", "MD5-1", None, date, version, RequestType.Delete),
/* Next 2 will not be taken into account since 'filterDoNotSellBy' is not set */
CcpaRequestIds("luid", "2", date, None, version, RequestType.DoNotSell),
CcpaRequestIds("hemlmd5", "MD5-2", date, None, version, RequestType.DoNotSell)
/* Only last record will be taken into account but not the next one since filtering of 'ATT'
* IDs is requsted for MD5 and SHA1 and not for LUID */
)
val requestedIds =
Seq( // First 2 will not be taken into account since this app for 'Do Not Sell' and 'ATT' only
CcpaRequestIds("luid", "1", None, date, version, RequestType.Delete),
CcpaRequestIds("hemlmd5", "MD5-1", None, date, version, RequestType.Delete),
/* Next 2 will not be taken into account since 'filterDoNotSellBy' is not set */
CcpaRequestIds("luid", "2", date, None, version, RequestType.DoNotSell),
CcpaRequestIds("hemlmd5", "MD5-2", date, None, version, RequestType.DoNotSell)
/* Only last record will be taken into account but not the next one since filtering of 'ATT'
* IDs is requsted for MD5 and SHA1 and not for LUID */
)
}
<<< binpack=oneline, with trailing-wrapped comment, narrower
maxColumn = 90
Expand All @@ -549,16 +549,16 @@ object a {
}
>>>
object a {
val foo = Seq( /* First 2 will not be taken into account since this app for 'Do Not
* Sell' */
CcpaRequestIds("luid", "1", None, date, version, RequestType.Delete),
CcpaRequestIds("hemlmd5", "MD5-1", None, date, version, RequestType.Delete),
/* Next 2 will not be taken into account since 'filterDoNotSellBy' is not set */
CcpaRequestIds("luid", "2", date, None, version, RequestType.DoNotSell),
CcpaRequestIds("hemlmd5", "MD5-2", date, None, version, RequestType.DoNotSell)
/* Only last record will be taken into account but not the next one since filtering of
* 'ATT' IDs is requsted for MD5 and SHA1 and not for LUID */
)
val foo =
Seq( // First 2 will not be taken into account since this app for 'Do Not Sell'
CcpaRequestIds("luid", "1", None, date, version, RequestType.Delete),
CcpaRequestIds("hemlmd5", "MD5-1", None, date, version, RequestType.Delete),
/* Next 2 will not be taken into account since 'filterDoNotSellBy' is not set */
CcpaRequestIds("luid", "2", date, None, version, RequestType.DoNotSell),
CcpaRequestIds("hemlmd5", "MD5-2", date, None, version, RequestType.DoNotSell)
/* Only last record will be taken into account but not the next one since filtering
* of 'ATT' IDs is requsted for MD5 and SHA1 and not for LUID */
)
}
<<< binpack=oneline, trailing-wrapped comment, narrower
maxColumn = 90
Expand Down

0 comments on commit e8ebc3c

Please # to comment.