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

Can't uncomment HTML in JSX files #248

Closed
kkoomen opened this issue Mar 15, 2019 · 18 comments
Closed

Can't uncomment HTML in JSX files #248

kkoomen opened this issue Mar 15, 2019 · 18 comments

Comments

@kkoomen
Copy link

kkoomen commented Mar 15, 2019

No matter which keystroke I use, I can't uncomment HTML in JSX files.

tcomment-jsx-uncomment-bug

@tomtom
Copy link
Owner

tomtom commented Mar 16, 2019

Could you please tell me, at each step, the result of :call tcomment#debug#CollectInfo() at the beginning of the line in question. Thanks.

@kkoomen
Copy link
Author

kkoomen commented Mar 16, 2019

| = cursor

Scenario

import React, { Component } from 'react';

class Test extends Component {
  render() {
    return (
      |<div className="Test" />
    );
  }
}

export default Test;

Debug

TCOMMENT: &ft = javascript.jsx
TCOMMENT: ft  = javascript.jsx
TCOMMENT: stx = jsx
TCOMMENT: ct  = {'commentstring': '{/* %s */}', 'mode': '', 'filetype': 'jsx'}

Scenario (pressed gcc)

import React, { Component } from 'react';

class Test extends Component {
  render() {
    return (
      |{/* <div className="Test" /> */}
    );
  }
}

export default Test;

Debug


TCOMMENT: &ft = javascript.jsx
TCOMMENT: ft  = javascript.jsx
TCOMMENT: stx = javascriptObjectBraces
TCOMMENT: ct  = {'rxmid': '', 'rxend': '', 'commentstring': '// %s', 'commentstring_rx': '\%%(// %s\|/* %s */\)', 'mode': '', 'filetype': 'javascript', 'replacements': {'*/': {'subst': '|)}>#', 'guard_rx': '^\s*/\?\*'}, '/*': {'subst': '#<{(|', 'guard_rx': '^\s*/\?\*'}}, 'rxbeg': '\*\+'}

I think this should already give you enough information.

@tomtom
Copy link
Owner

tomtom commented Mar 17, 2019 via email

@tomtom tomtom closed this as completed in c783fe4 Mar 17, 2019
@tomtom
Copy link
Owner

tomtom commented Mar 17, 2019

BTW what software did you use to create the screencast?

@kkoomen
Copy link
Author

kkoomen commented Mar 17, 2019

@tomtom It does makes sense, but here's the thing: JSX should use {/* ... /*} only when the cursor is in or surrounded by HTML. When the cursor is at a location which is just javascript, it should just the // plain javascript syntax. Will you fix this? Because you closed this issue without reason.


I used Kap to record a part of the screen.

@tomtom
Copy link
Owner

tomtom commented Mar 17, 2019 via email

@kkoomen
Copy link
Author

kkoomen commented Mar 18, 2019

@tomtom I pulled from master and this is indeed fixed. Thanks!

@alextes
Copy link

alextes commented Mar 21, 2019

@tomtom thanks for another improvement!
This has been bugging me since you last made the improvements that made commenting work well (thanks!), which sadly revealed the uncommenting to still be troublesome. I felt guilty continuously asking for improvements, when you'd already been responsive and helpful, and decided to wait until it bugged me enough to open a PR. I see it's already picked up! Thanks for that!

Sadly, this doesn't seem to be working for me. Can we reopen?
Version is 46d8351, which is master as of right now.
Keystrokes are: gcc gcc g<c g<c
Debug info for each step, starting with the state before any commenting is:

TCOMMENT: &ft = javascript.jsx
TCOMMENT: ft  = javascript.jsx
TCOMMENT: stx = jsx
TCOMMENT: ct  = {'commentstring': '{/* %s */}', 'commentstring_rx': '\%%(// %s\|{/* %s */}\)', 'mode': '', 'filetype': 'jsx'}
TCOMMENT: &ft = javascript.jsx
TCOMMENT: ft  = javascript.jsx
TCOMMENT: stx = javascriptBraces
TCOMMENT: ct  = {'rxmid': '', 'rxend': '', 'commentstring': '// %s', 'commentstring_rx': '\%%(// %s\|/* %s */\)', 'mode': '', 'filetype': 'javascript', 'replacements': {'*/': {'subst': '|)}>#', 'guard_rx': '^\s*/\?\*'}, '/*': {'subst': '#<{(|', 'guard_rx': '^\s*/\?\*'}}, 'rxbeg': '\*\+'}

TCOMMENT: &ft = javascript.jsx
TCOMMENT: ft  = javascript.jsx
TCOMMENT: stx = jsxRegion
TCOMMENT: ct  = {'commentstring': '{/* %s */}', 'commentstring_rx': '\%%(// %s\|{/* %s */}\)', 'mode': '', 'filetype': 'jsx'}

comment-jsx-1

Same for tsx files.

Let me know if I can be of any more help!

@alextes
Copy link

alextes commented Mar 21, 2019

@kkoomen this Kap thing is neat by the way. If I can ever offer you a hot thank you beverage of choice let me know!

@kkoomen
Copy link
Author

kkoomen commented Mar 21, 2019

demo-tcomment-working

@alextes I am on 46d8351 as well now and this is what I have ^ -- which works as expected, so re-opening is not needed I suppose. Do you have neovim?

@alextes
Copy link

alextes commented Mar 22, 2019

@kkoomen yup, neovim, I'll try and rule out plugins.

@alextes
Copy link

alextes commented Mar 22, 2019

othree/yajs.vim and mxw/vim-jsx together break this. Thanks for the hint kkoomen. I'll see if I can solve it. Mind telling me what you use for JSX highlighting in the meantime?

@tomtom
Copy link
Owner

tomtom commented Mar 22, 2019 via email

@alextes
Copy link

alextes commented Mar 22, 2019

Yup, certain @tomtom , but a friendly person already pointed out it's plugins interfering. To be specific ohtree/yajs.vim doesn't assign a jsx syntax group but a JS one. I'll link the issue when I get around to creating it.

@kkoomen
Copy link
Author

kkoomen commented Mar 23, 2019

@alextes I had some issues once using vim-jsx before, but they seem to be solved.

I am using vim-polyglot these days which supports a massive amount of languages to get a good syntax highlighting. It is an up-to-date repository. I do recommend to use this rather then scraping your own packages of the internet ;)

@andrescuco
Copy link

Recently I've come across the same issue. Except that I've tried pretty much every jsx syntax plugin and it still gives me the behavior described by OP. Using vim-polyglot doesn't work either. If this is an issue with the jsx syntax plugins and not related to tcomment please let me know and I'll open an issue in the correct repo. I'll post the result of tcomment#debug#CollectInfo() when trying to uncomment JSX if it's of any help. I'm using a .js file, but the behavior using .jsx / .tsx is the same.

TCOMMENT: &ft = javascript => javascript
TCOMMENT: stx = jsxElement => jsxElement
TCOMMENT: ct  = {'rxmid': '', 'rxend': '', 'commentstring': '// %s', 'commentstring_rx': '\%%(// %s\|/* %s */\)', 'mode': '', 'filetype': 'javascript', 'replacements': {'*/': {'subst': '|)}>#', 'guard_rx': '^\s*/\?\*'}, '/*': {'subst': '#<{(|', 'guard_rx': '^\s*/\?\*'}}, 'rxbeg': '\*\+'}

@tomtom
Copy link
Owner

tomtom commented Oct 9, 2020

I'm sorry but I cannot follow the thread that closely. Could you please describe exactly what you're trying to achieve. JSX files seem to work fine with the default vim plugins. But I don't do jsx and I need some help to find out what's going wrong.

It would also help if you installed tlib and the run Tlibtraceset --file=tcomment.log +tcommentas described in :help tcomment-debug.

@andrescuco
Copy link

@tomtom It's the same issue with uncommenting discussed earlier (gif originally by alextes):

comment-jsx-1

Here's the output of running Tlibtraceset --file=tcomment.log +tcomment: https://pastebin.com/pQd00zqV

As of jsx-plugins I'm using vim-polyglot but I've used pretty much all of jsx plugins available right now and the issue still persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants