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..073a915249e 100644 --- a/tests/slow/src/test/scala/tests/scalacli/ScalaCliSuite.scala +++ b/tests/slow/src/test/scala/tests/scalacli/ScalaCliSuite.scala @@ -1,6 +1,7 @@ package tests.scalacli import scala.concurrent.Future +import scala.concurrent.Promise import scala.meta.internal.metals.DebugUnresolvedMainClassParams import scala.meta.internal.metals.FileOutOfScalaCliBspScope @@ -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(