Skip to content

Commit

Permalink
fix: Semantic tokens misaligned in triple quote s-string
Browse files Browse the repository at this point in the history
  • Loading branch information
jkciesluk authored and tgodzik committed Aug 16, 2023
1 parent 0421dd0 commit 64631fc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ object SemanticTokensProvider {
delta = delta.moveLine(1)
}
}
delta = Line(0, lines.last.length())
if (lines.last.isEmpty()) delta = Line(1, 0)
else delta = Line(0, lines.last.length())
} else {
val lines = text.split("\n", -1)
if (lines.length > 1) delta = delta.moveLine(lines.length - 1)
Expand Down
22 changes: 22 additions & 0 deletions tests/unit/src/test/scala/tests/SemanticTokensLspSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,28 @@ class SemanticTokensLspSuite extends BaseLspSuite("SemanticTokens") {
|}""".stripMargin,
)

check(
"interpolated-string",
s"""|<<package>>/*keyword*/ <<a>>/*namespace*/
|<<object>>/*keyword*/ <<A>>/*class*/ {
|<<s>>/*keyword*/<<\"\"\">>/*string*/
|<<some text>>/*string*/
|<<\"\"\">>/*string*/
|}
|""".stripMargin,
)

check(
"interpolated-string2",
s"""|<<package>>/*keyword*/ <<a>>/*namespace*/
|<<object>>/*keyword*/ <<A>>/*class*/ {
|<<s>>/*keyword*/<<\"\"\">>/*string*/
|<<some text>>/*string*/
|<< >>/*string*/<<\"\"\">>/*string*/
|}
|""".stripMargin,
)

def check(
name: TestOptions,
expected: String,
Expand Down

0 comments on commit 64631fc

Please sign in to comment.