textmate / ruby.tmbundle

TextMate support for Ruby
178 stars 90 forks source link

Syntax highlight of Ruby is broken on percent notations #140

Open alexr00 opened 2 years ago

alexr00 commented 2 years ago

Originally from @takaram in https://github.com/microsoft/vscode/issues/137713

Does this issue occur when all extensions are disabled?: Yes

Steps to Reproduce:

  1. Create .rb file
  2. Input code like below
    puts %(() parentheses)
    puts %<{} braces>
    puts %Q{[] brackets}
    puts %r[[^a-z]]
    puts %(
    def foo()
    puts 123
    rescue
    nil
    end
    )
    puts %x(echo '() parentheses')

Expected: The literal is recognized as strings (or regexp) until the closing bracket. Specification of Ruby percent notations: http://www.chrisrolle.com/en/blog/ruby-percentage-notations

Actual: image

RedCMD commented 11 months ago

@alexr00 This issue is actually caused by a VSCode textmate bug

https://github.com/microsoft/vscode-textmate/issues/140

Nested 'repository"'s only seem to work if there is no "match" or "begin" rule at the same level as it (or "include" if they are inside a "patterns" array vs a "repository" item)

a temp work around is to nest everything except the 'repository" into a "patterns" array image

https://github.com/textmate/ruby.tmbundle/blob/efcb8941c701343f1b2e9fb105c678152fea6892/Syntaxes/Ruby.plist#L2136-L4209

alexr00 commented 11 months ago

@RedCMD thank you for root causing this!