From 8d589bb5e2ef0f5381d022429c6177fe646fea29 Mon Sep 17 00:00:00 2001 From: Karan Ahlawat Date: Fri, 20 Oct 2023 14:15:29 +0530 Subject: [PATCH] bugfix: fix SymbolNotFound regex This fixes the bug where the user has -explain scalac flag set and executing Code Actions on a missing symbol did not offer to import the symbol, due to extra text the regex previously failed to parse. --- .../scala/scala/meta/internal/metals/ScalacDiagnostic.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 } }