From 5f262d82a6717609f09194e094d70ffd7b6fff84 Mon Sep 17 00:00:00 2001 From: Brice Jaglin Date: Fri, 27 Sep 2024 22:14:47 +0200 Subject: [PATCH] ensure atomicity when global imports are added --- .../scala-3/pc/PresentationCompilerTypeInferrer.scala | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scalafix-rules/src/main/scala-3/pc/PresentationCompilerTypeInferrer.scala b/scalafix-rules/src/main/scala-3/pc/PresentationCompilerTypeInferrer.scala index 6326552fa..5063f95d0 100644 --- a/scalafix-rules/src/main/scala-3/pc/PresentationCompilerTypeInferrer.scala +++ b/scalafix-rules/src/main/scala-3/pc/PresentationCompilerTypeInferrer.scala @@ -59,8 +59,7 @@ final class PresentationCompilerTypeInferrer private ( replace.pos.end ) val result = pc.insertInferredType(params).get() - // TODO we need to actually insert after each change - val allPatches: List[Patch] = result.asScala.toList + result.asScala.toList .map { edit => val start = edit.getRange().getStart() val last = ctx.tokens.tokens.takeWhile { token => @@ -72,9 +71,8 @@ final class PresentationCompilerTypeInferrer private ( }.last Patch.addRight(last, edit.getNewText()) } - allPatches.reduce[Patch] { case (p1, p2) => - p1 + p2 - } + .asPatch + .atomic } }