vscode-crystal-lang icon indicating copy to clipboard operation
vscode-crystal-lang copied to clipboard

Heredoc syntax highlighting is incorrect

Open HertzDevil opened this issue 2 years ago • 1 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.)

HertzDevil avatar Oct 05 '21 16:10 HertzDevil

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

HertzDevil avatar Oct 05 '21 16:10 HertzDevil

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

nobodywasishere avatar Dec 06 '23 04:12 nobodywasishere