atom-react icon indicating copy to clipboard operation
atom-react copied to clipboard

end-of-line comments don't get highlighted

Open evandavis opened this issue 9 years ago • 5 comments

a comment at the end of a line inside a JSX component declaration doesn't get picked up and highlighted, see below:

screenshot 2015-07-14 12 13 15

evandavis avatar Jul 14 '15 16:07 evandavis

Looks like its a problem of your UI scheme. I can't reproduce it on my Seti UI.

stremlenye avatar Jul 17 '15 10:07 stremlenye

It's a missing rule in the grammar! I'll fix this ASAP.

orktes avatar Jul 17 '15 11:07 orktes

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.

image

@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

softwarecreations avatar Jul 06 '17 08:07 softwarecreations

@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

image

So a temporary workaround until this is fixed is to simply include a space after < operators in instances where the grammar breaks.

softwarecreations avatar Jul 06 '17 09:07 softwarecreations

It's not specific to for loops image

image the reason < is highlighted is because I was searching for it in other code.

image

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.

image

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)

softwarecreations avatar Jul 06 '17 10:07 softwarecreations