ruby-block icon indicating copy to clipboard operation
ruby-block copied to clipboard

Highlighting does not work for grammar 'Ruby' files only 'Ruby on Rails' grammar

Open rogerprz opened this issue 6 years ago • 7 comments

New to submitting bug issues, but wanted to see if anyone else was experiencing the same.

By default Atom detects my .rb file as grammar for 'Ruby' file. The highlighting wasn't working until I switched from 'Ruby' to 'Ruby on Rails'.

Request: Able to detect and use in multiple 'Ruby*' grammar detections by default or checkbox ability.

screen shot 2019-01-11 at 12 54 38 pm

rogerprz avatar Jan 11 '19 20:01 rogerprz

I am seeing the same behavior.

kimbernator avatar Jan 14 '19 17:01 kimbernator

It looks like the issue is a result of Tree-Sitter parsing. The quick fix for this is to uncheck "Use Tree Sitter Parsers" in the Atom settings menu.

When that setting is enabled, the function return in ruby-block.coffee takes place when this condition is checked:

return if cursor.getScopeDescriptor().scopes.indexOf(@rubyKeywordControlScope) is -1 when @rubyKeywordControlScope is set to 'keyword.control.ruby'

Rails is not using Tree-Sitter, so it uses a different layout for the array of scopes.

cursor.getScopeDescriptor().scopes in Ruby: Tree-Sitter Parsing off: ["source.ruby", "keyword.control.ruby"] Tree-Sitter Parsing on: ["source.ruby", "keyword.control"]

I made some quick adjustments to get the constructor name for the grammar object (TreeSitterGrammar vs. Grammar) and check the arrays appropriately, but that introduces other objects later in the code (tokenizeLine is not an available method anymore).

kimbernator avatar Jan 14 '19 19:01 kimbernator

Great. That worked. screen shot 2019-01-15 at 8 59 19 am

rogerprz avatar Jan 15 '19 16:01 rogerprz

Is this an issue that is likely to be fixed in this project, or is this a problem with Tree Sitter parsers and we're waiting for an upstream fix?

nickpresta avatar Feb 20 '19 14:02 nickpresta

Not working for me: Atom v1.34.0 x64 on Ubuntu 18.04 Tried disabling the Tree Sitter Parsers as per above instructions, but no joy. Also tried switching grammar to Ruby on Rails. No highlighting or other good behavior observed in any of these settings.

LorinRicker avatar May 22 '19 17:05 LorinRicker

Sort of works for me. If I click on the block end it will highlight the bock beginning, but not the other way around. Not terribly helpful after I've already located the block end.

atstockland avatar Jan 27 '21 06:01 atstockland

It is kind of hidden, that, to get Ruby Block to work, you have to Uncheck "Use Tree Sitter Parsers"

Will there be any work to allow this package to work with "Use Tree Sitter Parsers" checked? Or, any communication to people downloading this package that they need to uncheck "Use Tree Sitter Parsers"?

snackattas avatar Feb 20 '21 20:02 snackattas