lexical-lsp / vscode-lexical

VSCode extension for Lexical, the modern Elixir language server
Apache License 2.0
36 stars 6 forks source link

HEEx heredoc wrapped in function breaks further highlighting #77

Closed zolrath closed 5 months ago

zolrath commented 5 months ago

Hello! When using a HEEx heredoc within a function the """) section causes further syntax highlighting to break.

  test "breaks syntax highlighting" do
    assigns = %{}
    example = "Hello"

    assert example =~ "Hello"

    component =
      rendered_to_string(~H"""
      <.thing type="test" />
      """)

    assert component =~ "This should be green"
  end

Seems like it works properly on GitHub, here's a screenshot from VS Code!  image

Thanks for the great work on Lexical!

Blond11516 commented 5 months ago

Hi @zolrath!

Thanks a lot for the report, but I believe this is an issue with the Phoenix Framework extension rather than Lexical. Their grammar for the H sigil enforces that the heredoc delimiters (sequence of 3 double quotes) appears at the very end of the line (with optional sigil arguments). This is what causes """) to not be interpreted as closing the sigil and the rest of the document is thus interperted as being part of the sigil.

Interestingly, this only appears to be the case with heredoc separators. None of the other separators have this requirement.

I've also confirmed that both elixir-ls and elixir-tools share the same issue.

I'd suggest you open an issue/PR over on the vscode-phoenix repo. I think the fix might be as simple as removing the $ from the end of line 14 but I'm not sure if there was a specific reason for having it in the first place.

zolrath commented 5 months ago

Oh dang, I thought I had removed all other Elixir/Phoenix extensions before reporting this, sorry about that! I'll make a PR over there, thanks!

Blond11516 commented 5 months ago

No worries, mistakes happen!

Adding links to the vscode-phoenix issue and corresponding PR for future reference: