crystal-lang-tools/vscode-crystal-lang

Heredoc syntax highlighting is incorrect

HertzDevil opened this issue · 2 comments

  • Everything after the heredoc start delimiter is not highlighted. Those characters are never part of the heredoc, so they should receive regular highlighting.
  • If there are multiple heredocs created on the same line, only the first end delimiter is highlighted and subsequent heredocs are highlighted as if they are regular code.

Screenshot_20211006_002204

For comparison, here is how the same code looks like in Ruby:

Screenshot_20211006_002300

(It appears they use only the last heredoc name as the delimiter for all heredocs that immediately follow.)

This happens with GitHub itself too, so it should not be used as a guide of correctness:

# crystal
foo(<<-EOS, 1)
abcde
EOS

foo(<<-EOS, <<-MSG)
  1
  EOS
  2
  MSG
# ruby
foo(<<-EOS, 1)
abcde
EOS

foo(<<-EOS, <<-MSG)
  1
  EOS
  2
  MSG

Related: crystal-lang-tools/language-crystal#29

I don't think this is possible to fix without tree-sitter or an LSP, due to the complexity of Heredocs.