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

FormatWriter: add ft method to AlignStop #3920

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,7 @@ class FormatWriter(formatOps: FormatOps) {
block.foreach { x =>
if (x.style.align.multiline) {
val headStop = x.stops.head
val ftIndex = headStop.floc.formatToken.meta.idx
val ftIndex = headStop.ft.meta.idx
if (ftIndex < endIndex) shiftStateColumnIndent(
ftIndex + 1,
block.stopColumns.head - headStop.column,
Expand All @@ -1347,7 +1347,7 @@ class FormatWriter(formatOps: FormatOps) {
val currentShift = blockStop - stop.column
val offset = currentShift - previousShift
previousShift = currentShift
builder += stop.floc.formatToken.meta.idx -> offset
builder += stop.ft.meta.idx -> offset
}
}
}
Expand Down Expand Up @@ -1663,7 +1663,10 @@ object FormatWriter {
val floc: FormatLocation,
val hashKey: Int,
val nonSlcOwner: Option[Tree],
)
) {
@inline
def ft = floc.formatToken
}

class AlignLine(
var stops: IndexedSeq[AlignStop],
Expand Down Expand Up @@ -1745,7 +1748,7 @@ object FormatWriter {
if (matches == 0 || matches >= oldStops || matches >= newStops) 0
else if (oldStops < newStops) -1 // new is longer
else if (oldStops > newStops || hasMultiple) 1 // old is longer
else if (line.stops.last.floc.formatToken.right.is[T.Comment]) 1
else if (line.stops.last.ft.right.is[T.Comment]) 1
else -1
}

Expand Down
Loading