#426 new
y_feldblum (at yahoo)

<<- strings not highlighting correctly

Reported by y_feldblum (at yahoo) | December 9th, 2010 @ 09:10 PM

Ruby syntax permits usage such as

a = <<-ENDDOC.lines.map(&:strip).join
  a927fd92a927fd92a927fd92a927fd92
  a927fd92a927fd92a927fd92a927fd92
  a927fd92a927fd92a927fd92a927fd92
  a927fd92a927fd92a927fd92a927fd92
ENDDOC

In this example, .lines.map(&:strip).join should not be highlighted as being part of the string. They should be highlighted as regular Ruby method calls. Only the prhase <<-ENDDOC by itself, and the lines following until ENDDOC, should be highlighted.

However, I wonder if it is even possible to parse this using modern simple parsers.

Comments and changes to this ticket

  • tim.felgentreff (at student.hpi.uni-potsdam)

    tim.felgentreff (at student.hpi.uni-potsdam) February 19th, 2011 @ 01:15 PM

    Is this working correctly in Textmate? The Textmate Ruby bundle has a lengthy comment on heardocs to explain how and why they are broken. There simply isn't a way for us to highlight every use of them correctly within the constraints of Textmate grammars. But if it works on TM, it should work on Redcar.

  • ronin-98500 (at lighthouseapp)

    ronin-98500 (at lighthouseapp) February 27th, 2011 @ 04:08 PM

    There are other uses of heredocs that aren't highlighted correctly, e.g.

    foo(<<EOF)
    This
    is
    a
    string
    EOF
    

    or

    def foo
      <<EOF
    This
    is
    a
    string
    EOF
    end
    

    Both don't highlight the heredoc as a string, but as Ruby code. But these uses aren't that common I think, so it's probably OK to not highlight them correctly. I'm on Linux, so no Textmate to test with. :-(

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

A programmer's text editor for Gnome.

People watching this ticket

Pages