diff --git a/metals/src/main/scala/scala/meta/internal/metals/ScalacDiagnostic.scala b/metals/src/main/scala/scala/meta/internal/metals/ScalacDiagnostic.scala index c0cd5350237..db35cda94db 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/ScalacDiagnostic.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/ScalacDiagnostic.scala @@ -28,10 +28,10 @@ object ScalacDiagnostic { } object SymbolNotFound { - private val regex = """(n|N)ot found: (value|type)?\s?(\w+)""".r + private val regex = """(n|N)ot found: (value|type)?\s?(\w+)(\s|\S)*""".r def unapply(d: l.Diagnostic): Option[String] = d.getMessage().trim() match { - case regex(_, _, name) => Some(name) + case regex(_, _, name, _) => Some(name) case _ => None } } diff --git a/tests/unit/src/test/scala/tests/codeactions/ImportMissingSymbolLspSuite.scala b/tests/unit/src/test/scala/tests/codeactions/ImportMissingSymbolLspSuite.scala index eda8c2ab217..91055b0f44f 100644 --- a/tests/unit/src/test/scala/tests/codeactions/ImportMissingSymbolLspSuite.scala +++ b/tests/unit/src/test/scala/tests/codeactions/ImportMissingSymbolLspSuite.scala @@ -261,4 +261,27 @@ class ImportMissingSymbolLspSuite |""".stripMargin, ) + check( + "scalac-explain-flag", + """|package a + | + |object A { + | val f = <>.successful(2) + |} + |""".stripMargin, + s"""|${ImportMissingSymbol.title("Future", "scala.concurrent")} + |${ImportMissingSymbol.title("Future", "java.util.concurrent")} + |${CreateNewSymbol.title("Future")} + |""".stripMargin, + """|package a + | + |import scala.concurrent.Future + | + |object A { + | val f = Future.successful(2) + |} + |""".stripMargin, + scalaVersion = "3.3.1", + scalacOptions = List("-explain"), + ) }