HarlemSquirrel / language-haml

Haml language grammar for GitHub's Atom IDE
MIT License
33 stars 24 forks source link

Filter highlighting only works up to first linebreak #44

Closed olivierlacan closed 8 years ago

olivierlacan commented 9 years ago

@ezekg You asked for feedback and this is the only odd thing I've noticed since the last release (0.22.2):

This :javascript filter is highlighted properly: image

While this one isn't: image

If I remove the new line between the first var declaration and the second, the highlighting turns back on: image

ezekg commented 9 years ago

Thanks. I've had a really tough time with this one. I can't find a good regex for matching a filter's 'end' when the white space gets trimmed. If you left the white space there, it would work fine. But, since it gets trimmed, the regex thinks that the filter has been exited and that the remaining text is plaintext. You can see the issue with the trimmed whitespace below (one has been trimmed, the other hasn't):

image

If I do it the way it was done before, all text below the filter gets highlighted wrong if there's no newline between the filter and any regular Haml directly following the filter (sometimes the highlighting is wrong regardless of whether there's a newline or not, oddly). I chose the lesser of the 2 evils for now, because having an entire file with broken syntax highlighting isn't fun.

Maybe there's a way to track the amount of indentation and only exit when that goes below a certain threshold, but I'm not entirely sure that's possible with just a couple regexes.

olivierlacan commented 9 years ago

I knew my pedantic whitespace trimming ways would one day come to bite me again. :-)

This is really a tricky one. I'll ask people more familiar with fancy regex.

ezekg commented 9 years ago

Let me know if you figure anything out. I've tried multiple ways, but nothing seems to handle every edge case. If only a regex could keep a counter... lol.

ezekg commented 9 years ago

Digging in more. You would have to be able to handle cases like this:

- some_ruby do
  :coffee
    class Klass

      constructor: () ->
        do someFunc
        # ...
  Some plain text here...
  - some_more_ruby do
    :coffee
      do something -> @.somethingElse()
      # ...
    - ruby_stuff "after", :filters
  = and_more_ruby "here"

As you can see, I think Github's syntax highlighting handles this the same way I'm currently handling it. (...unless it's actually depending on this package :boom:)

ezekg commented 8 years ago

Figured it out. Let me know if you find any issues. :+1:

olivierlacan commented 8 years ago

Nice! Checking it out :-)

olivierlacan commented 8 years ago

Fix confirmed, great work @ezekg! :smile_cat:

ezekg commented 8 years ago

Boom! 0 open issues.

( •_•)
( •_•)>⌐■-■
(⌐■_■)