Skip to content

Commit

Permalink
FormatWriter: use largest align owner on a line
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Sep 20, 2021
1 parent 75c4846 commit 0a5272d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,14 @@ class FormatWriter(formatOps: FormatOps) {
getAlignContainer(floc).foreach { container =>
if (alignContainer eq null)
alignContainer = container
else if (alignContainer ne container) {
val pos1 = alignContainer.pos
val pos2 = container.pos
if (pos2.start <= pos1.start && pos2.end >= pos1.end) {
alignContainer = container
columnCandidates.clear()
}
}
if (alignContainer eq container)
columnCandidates += new AlignStop(
getAlignColumn(floc) + columnShift,
Expand Down
12 changes: 6 additions & 6 deletions scalafmt-tests/src/test/resources/align/DefaultWithAlign.stat
Original file line number Diff line number Diff line change
Expand Up @@ -1445,11 +1445,11 @@ object Thing {
object Thing {
def apply(foo: FooBaz.booberry, someInt: Int, booControl: Option[OptionalBooberryParams])(implicit p: Parameters): FooBaz =
apply(policy, Some(beatBytes), booControl)
def apply(foo: FooBaz.booberry, someInt: Int)(implicit p: Parameters): FooBaz =
def apply(foo: FooBaz.booberry, someInt: Int)(implicit p: Parameters): FooBaz =
apply(policy, Some(beatBytes), booControl = None)
def apply(fooBaz: Int, someBooberry: Option[OptionalBooberryParams])(implicit p: Parameters): FooBaz =
def apply(fooBaz: Int, someBooberry: Option[OptionalBooberryParams])(implicit p: Parameters): FooBaz =
apply(policy = FooBaz.booberry, Some(someInt), booControl)
def apply(fooBaz: Int)(implicit p: Parameters): TLNode =
def apply(fooBaz: Int)(implicit p: Parameters): TLNode =
apply(policy = FooBaz.booberry, Some(someInt), booControl = None)
}
<<< #2750 3 blocks, blanks
Expand Down Expand Up @@ -1522,13 +1522,13 @@ object Thing {
def apply(foo: FooBaz.booberry, someInt: Int, booControl: Option[OptionalBooberryParams])(implicit p: Parameters): FooBaz = {
apply(policy, Some(beatBytes), booControl)
}
def apply(foo: FooBaz.booberry, someInt: Int)(implicit p: Parameters): FooBaz = {
def apply(foo: FooBaz.booberry, someInt: Int)(implicit p: Parameters): FooBaz = {
apply(policy, Some(beatBytes), booControl = None)
}
def apply(fooBaz: Int, someBooberry: Option[OptionalBooberryParams])(implicit p: Parameters): FooBaz = {
def apply(fooBaz: Int, someBooberry: Option[OptionalBooberryParams])(implicit p: Parameters): FooBaz = {
apply(policy = FooBaz.booberry, Some(someInt), booControl)
}
def apply(fooBaz: Int)(implicit p: Parameters): TLNode = {
def apply(fooBaz: Int)(implicit p: Parameters): TLNode = {
apply(policy = FooBaz.booberry, Some(someInt), booControl = None)
}
}

0 comments on commit 0a5272d

Please sign in to comment.