From 8100b5c897bacbd70d5a045f40fd793b69af893f Mon Sep 17 00:00:00 2001 From: Jakub Ciesluk <323892@uwr.edu.pl> Date: Mon, 9 Oct 2023 15:23:30 +0200 Subject: [PATCH] bugfix: Fix docstring regex in semantic highlighting --- .../scala/meta/internal/metals/SemanticTokensProvider.scala | 2 +- tests/unit/src/test/scala/tests/SemanticTokensLspSuite.scala | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metals/src/main/scala/scala/meta/internal/metals/SemanticTokensProvider.scala b/metals/src/main/scala/scala/meta/internal/metals/SemanticTokensProvider.scala index 3587294d44e..725cbdb62d1 100644 --- a/metals/src/main/scala/scala/meta/internal/metals/SemanticTokensProvider.scala +++ b/metals/src/main/scala/scala/meta/internal/metals/SemanticTokensProvider.scala @@ -413,7 +413,7 @@ object SemanticTokensProvider { object DocstringToken { val paramOrThrows: String = "(@param|@tparam|@throws)\\s+([\\w.]+)" - val apiLink: String = "\\[\\[(.*)\\]\\]" + val apiLink: String = "\\[\\[(.*?)\\]\\]" val other: String = "(@[a-zA-Z]+)" val reg: Regex = s"$paramOrThrows|$apiLink|$other".r diff --git a/tests/unit/src/test/scala/tests/SemanticTokensLspSuite.scala b/tests/unit/src/test/scala/tests/SemanticTokensLspSuite.scala index 93b5cb2b6b4..f348d88fdc6 100644 --- a/tests/unit/src/test/scala/tests/SemanticTokensLspSuite.scala +++ b/tests/unit/src/test/scala/tests/SemanticTokensLspSuite.scala @@ -82,7 +82,7 @@ class SemanticTokensLspSuite extends BaseLspSuite("SemanticTokens") { |<< * >>/*comment*/<<@param>>/*keyword*/<< >>/*comment*/<>/*variable,readonly*/<< is [[>>/*comment*/<>/*string*/<<]]>>/*comment*/ |<< * >>/*comment*/<<@throws>>/*keyword*/<< >>/*comment*/<>/*class*/<< is [[>>/*comment*/<>/*string*/<<]]>>/*comment*/ |<< * >>/*comment*/<<@return>>/*keyword*/<< the same list>>/*comment*/ - |<< * >>/*comment*/<<@note>>/*keyword*/<< This is a note>>/*comment*/ + |<< * >>/*comment*/<<@note>>/*keyword*/<< This is a note [[>>/*comment*/<>/*string*/<<]] or [[>>/*comment*/<>/*string*/<<]]>>/*comment*/ |<< */>>/*comment*/ | <>/*keyword*/ <>/*method,definition*/(<>/*parameter,declaration,readonly*/: <>/*type*/[<>/*class,abstract*/]): <>/*type*/[<>/*class,abstract*/] = <>/*parameter,readonly*/ |}