Skip to content
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

Toggling comment of a first line of JSX in a block does not work #11

Closed
JoosepAlviste opened this issue Jun 3, 2021 · 3 comments
Closed
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@JoosepAlviste
Copy link
Owner

JoosepAlviste commented Jun 3, 2021

If I comment out twice in tsx, it will behave strangely.

CleanShot 2021-06-03 at 00 59 55@2x
require("kommentary.config").configure_language("typescriptreact", {
    hook_function = function()
       pre_comment_hook = require('ts_context_commentstring.internal').update_commentstring()
    end,
    prefer_single_line_comments = true,
})

The issue is that if you comment the first line (only the first line) in any JSX block, then there will be a syntax error. For example, this is not valid JS/JSX:

const App = () => (
  {/* <div> */}
    <p>Hello world</p>
  </div>
)

Now, treesitter thinks that the first line of JSX with the comment is an object.

But I don't think that it's super high priority for now. I probably won't be dealing with it any time soon.

Initial issue from here: #10 (comment)

@josefvn
Copy link

josefvn commented Feb 1, 2022

I came across this bug today too, is this in essence, an issue that needs to be fixed in TreeSitter?

@JoosepAlviste
Copy link
Owner Author

Hey @sparkbuzz!

I don't think that this is a problem with treesitter because it makes sense that it can't parse the commented code, it's not actually valid syntax. So, I think that something should still be added to this plugin to handle the weird treesitter syntax tree, but it probably requires being able to write more complex configuration for commentstrings.

But there might be another good solution, I haven't given this issue too much thought.

@JoosepAlviste
Copy link
Owner Author

I'll close this in favor of #29 since that one has more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants