-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve commenting of JSX #21
Comments
I have updated the commenting behavior to match babel-sublime. (This is what it was supposed to be doing, but there were bugs.) However, this will not address all of the above concerns. The central problem is that JSX does not support comments. There is no JSX comment syntax at all, and it is unlikely that one will be added. In order to fake it, we use a double-wrapping approach, but that approach has fundamental flaws. In particular, it is impossible for this system to round-trip correctly in the general case. Consider these lines: <div>
{foo}
foo
</div> If you comment out the first One way to make it work would be to use a special labelled commenting syntax just for JSX text. For example, JSX text One specific problem that could perhaps be improved is removing the curly brackets when uncommenting. But this runs into round-trip issues as well. Consider the commented It's questionable whether the built-in commenting system (inherited from TextMate) can handle something much more complicated than the current system. I've experimented with a system that would hook in to and selectively override the built-in mechanism, but it never reached a favorable usefulness-to-hackiness ratio. There might be a reasonable middle ground using JS Custom's more detailed scoping, but there's an issue with selector scoring that would probably interfere with the nesting typical of JSX code. I am open to any suggestions you may have. I'm sure that we can improve on babel-sublime's commenting functionality. For now (as of the 1.0.10 release), it should at least match babel-sublime in this regard. |
(See also babel/babel-sublime#262) |
I don't have enough skill to understand how everything works so at the moment I think I can't help to solve this. |
Looks Like vscode handle jsx comments very good, maybe it can be useful for some inspiration. |
It does seem to do a good job overall, though there are some bugs. Integrating it into Sublime's commenting system might be tricky, but I'll look into it. |
Will this be of any use? https://programmingliftoff.com/enable-jsx-commenting-sublime-text-3/ |
Also, this package might help as a temporary solution (here).. It is working for me so far... |
JSX commenting should be significantly improved in v4 for ST4. |
I detected some problems with jsx comments.
Uncomment doesn't work
If I comment one line and then uncomment it, some curlybraces are being leaved behind.
before
after
should be
Indentation spaces shouldn't be included on the comment
before
after
should be
Inner component is not commented if indentation spaces are not selected
If you select a component like in the next screenshot the comment shortcut doesn't work
Use normal javascript comments instead of jsx when the code is inside parenthesis ()
before
after
should be
The javascript that Im using for this examples
The text was updated successfully, but these errors were encountered: