textmate / ruby.tmbundle

TextMate support for Ruby
178 stars 90 forks source link

Ruby heredoc in method arguments breaks parenthese recognition #124

Open alexr00 opened 5 years ago

alexr00 commented 5 years ago

From @amerov on November 8, 2018 21:16

The closing paren gets classified incorrectly as string.unquoted.heredoc.ruby on line 7.

Highlighting example, incorrect on the left, correct on the right. screenshot from 2018-11-09 02-15-58

Copied from original issue: Microsoft/vscode#62812

alexr00 commented 5 years ago

From @amerov on November 18, 2018 7:54

@alexr00 It is valid ruby code. Examples: https://github.com/rails/rails/blob/master/activemodel/lib/active_model/attributes.rb#L35 https://github.com/rails/rails/blob/master/activerecord/lib/active_record/persistence.rb#L659 https://github.com/rails/rails/blob/master/activerecord/lib/active_record/nested_attributes.rb#L370

alexr00 commented 5 years ago

From @rebornix on November 19, 2018 17:7

@alexr00 the heredoc content starts from the line following the heredoc identifier (LOG in our case) and we can use the heredoc identifier as a variable in that line, so log(<<-LOG) is a valid function call and <<-LOG is referring to the content after this line (and also ends with LOG). https://docs.ruby-lang.org/en/2.5.0/syntax/literals_rdoc.html

For short, ) is not part of the multiline string, our grammar is kind of wrong.

alexr00 commented 5 years ago

Thanks for checking!