atom-react
atom-react copied to clipboard
end-of-line comments don't get highlighted
a comment at the end of a line inside a JSX component declaration doesn't get picked up and highlighted, see below:

Looks like its a problem of your UI scheme. I can't reproduce it on my Seti UI
.
It's a missing rule in the grammar! I'll fix this ASAP.
EDIT: See my next post, I've figured out the cause of this particular bug that I'm experiencing below, it's very simple.
@evandavis Hi I'm also having this problem. I'm running the latest 1.16.2 release.
@orktes I'm guessing you became too busy to fix it?
Language selection: Javascript (JSX)
export const FooCt = createContainer(props => { //working comment
if (Meteor.subscribe('sub1', {}).ready()) { //working comment
if (dog!==undefined && dog.names) { //working comment
if (Meteor.subscribe('sub2', {}).ready()) { //working comment
if (Array.isArray(myArray) && myArray.length) { //working comment
for (let i=0;i<myArray.length;++i) console.log('foo'); //first broken comment. After this the rest will be broken nomatter how far down.
} //broken comment /*broken comment*/
} /*broken comment*/ //broken comment
} //broken comment /*broken comment*/
} /*broken comment*/ //broken comment
return {}; //broken comment /*broken comment*/
}, Foo); /*broken comment*/ //broken comment
//broken comment
/*broken comment*/
/*
broken comment
*/
I had a look at the grammar file now but I've not worked with Atom grammar files before and have no idea how to debug them. https://github.com/orktes/atom-react/blob/master/grammars/JavaScript%20(JSX).cson
@orktes I found the specific thing that breaks the grammar.
It's the less-than-operator <
inside the for loop when followed immediately by an operand without a space
So a temporary workaround until this is fixed is to simply include a space after <
operators in instances where the grammar breaks.
It's not specific to for loops
the reason
<
is highlighted is because I was searching for it in other code.
When the parser sees < followed by a number or letter it thinks it's a JSX open tag, and that's why comments aren't recognized after that point, because for the rest of the file it thinks it's inside a JSX tag. This appears to indicate another problem because JSX tags probably need to start with an alphabetical character, not a number.
My theory is proven correct here because as soon as I type the >
symbol it thinks I've closed the open part of the JSX tag and it auto-completes a closing </4>
tag. (displayed after my cursor)