diff --git a/metals/src/main/scala/scala/meta/internal/metals/Diagnostics.scala b/metals/src/main/scala/scala/meta/internal/metals/Diagnostics.scala index fa1368ee6c8..9eecc5c583e 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/Diagnostics.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/Diagnostics.scala @@ -267,6 +267,7 @@ final class Diagnostics( d.getSeverity, d.getSource, ) + if (d.getCode() != null) ld.setCode(d.getCode()) ld.setData(d.getData) ld } diff --git a/metals/src/main/scala/scala/meta/internal/metals/MetalsEnrichments.scala b/metals/src/main/scala/scala/meta/internal/metals/MetalsEnrichments.scala index 63874c75efd..fea17ca18f2 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/MetalsEnrichments.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/MetalsEnrichments.scala @@ -761,9 +761,10 @@ object MetalsEnrichments fansi.Str(diag.getMessage, ErrorMode.Strip).plainText, diag.getSeverity.toLsp, if (diag.getSource == null) "scalac" else diag.getSource, - // We omit diag.getCode since Bloop's BSP implementation uses 'code' with different semantics - // than LSP. See https://github.com/scalacenter/bloop/issues/1134 for details ) + if (diag.getCode() != null) { + ld.setCode(diag.getCode()) + } ld.setData(diag.getData) ld }