From 007da1db8164ce39f7384eba71113345313479b3 Mon Sep 17 00:00:00 2001 From: kasiaMarek Date: Tue, 10 Dec 2024 17:33:43 +0100 Subject: [PATCH] test: fix reindex scala-cli test --- .../scala/scala/meta/internal/metals/FileChanges.scala | 8 ++++---- .../src/test/scala/tests/scalacli/ScalaCliSuite.scala | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/metals/src/main/scala/scala/meta/internal/metals/FileChanges.scala b/metals/src/main/scala/scala/meta/internal/metals/FileChanges.scala index b4502de3cb3..e1d1d9f8c01 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/FileChanges.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/FileChanges.scala @@ -13,7 +13,7 @@ import ch.epfl.scala.bsp4j.BuildTargetIdentifier class FileChanges(buildTargets: BuildTargets, workspace: () => AbsolutePath)( implicit ec: ExecutionContext ) { - private val previousSignature = TrieMap[AbsolutePath, String]() + private val previousSignatures = TrieMap[AbsolutePath, String]() private val dirtyBuildTargets = mutable.Set[BuildTargetIdentifier]() def addAllDirty( @@ -121,10 +121,10 @@ class FileChanges(buildTargets: BuildTargets, workspace: () => AbsolutePath)( fingerprint .map { fingerprint => synchronized { - if (previousSignature.getOrElse(path, null) == fingerprint.md5) + if (previousSignatures.getOrElse(path, null) == fingerprint.md5) false else { - previousSignature.put(path, fingerprint.md5) + previousSignatures.put(path, fingerprint.md5) true } } @@ -132,5 +132,5 @@ class FileChanges(buildTargets: BuildTargets, workspace: () => AbsolutePath)( .getOrElse(true) } - def cancel(): Unit = previousSignature.clear() + def cancel(): Unit = previousSignatures.clear() } diff --git a/tests/slow/src/test/scala/tests/scalacli/ScalaCliSuite.scala b/tests/slow/src/test/scala/tests/scalacli/ScalaCliSuite.scala index ce477c7ec25..9533a77571f 100644 --- a/tests/slow/src/test/scala/tests/scalacli/ScalaCliSuite.scala +++ b/tests/slow/src/test/scala/tests/scalacli/ScalaCliSuite.scala @@ -15,6 +15,7 @@ import scala.meta.internal.mtags.CoursierComplete import org.eclipse.{lsp4j => l} import tests.FileLayout +import scala.concurrent.Promise // https://github.com/scalameta/metals/issues/6839 class ScalaCliSuite extends BaseScalaCliSuite("3.3.3") { @@ -504,9 +505,11 @@ class ScalaCliSuite extends BaseScalaCliSuite("3.3.3") { | ^^ |""".stripMargin, ) + _ = server.server.indexingPromise = Promise[Unit]() _ <- server.didSave("Main.scala") { text => text.replace("// >", "//>") } + _ <- server.server.indexingPromise.future // cause another compilation to wait on workspace reload, the previous gets cancelled _ <- server.didSave("Main.scala")(identity) _ = assertEquals(