Skip to content

Commit

Permalink
FormatTokensRewrite: simplify claiming on right
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Mar 28, 2024
1 parent 7b06e13 commit b7997bd
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ object FormatTokensRewrite {
if (
preClaimed && {
val oldrepl = tokens(claimedIdx)
oldrepl != null && oldrepl.idx == ftIdx
oldrepl == null || oldrepl.idx == ftIdx
}
) {
tokens(claimedIdx) = repl
Expand Down Expand Up @@ -438,15 +438,11 @@ object FormatTokensRewrite {
ft: FormatToken,
session: Session,
style: ScalafmtConfig
): Unit =
onRight(hasFormatOff) match {
case None =>
session.claim(null)
session.tokens(leftIdx) = null
case Some((ltRepl, rtRepl)) =>
session.claim(rtRepl)
session.tokens(leftIdx) = ltRepl
}
): Unit = {
val (ltRepl, rtRepl) = onRight(hasFormatOff).getOrElse((null, null))
session.claim(rtRepl)
session.tokens(leftIdx) = ltRepl
}
}

private[rewrite] sealed trait ReplacementType
Expand Down

0 comments on commit b7997bd

Please # to comment.