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

Comment shortcut is not correct in JSX #5291

Closed
adamsoutar opened this issue Jul 14, 2022 · 22 comments · Fixed by #17734
Closed

Comment shortcut is not correct in JSX #5291

adamsoutar opened this issue Jul 14, 2022 · 22 comments · Fixed by #17734
Labels
bug [core label] editor Feedback for code editing, formatting, editor iterations, etc javascript JavaScript programming language support tsx TypeScript JSX support

Comments

@adamsoutar
Copy link
Contributor

Describe the bug

When pressing the 'comment selected lines' shortcut (Cmd+/) in JSX, Zed inserts the wrong kind of comment.

To reproduce

Select some JSX tags, press Cmd+/ (default keymap)

Expected behavior

Zed should comment tags like so:

{/*<div>
  <p>Hello, world!</p>
</div>*/}

But instead, it does:

// <div>
//   <p>Hello, world!</p>
// </div>

This is not a valid way to comment JSX syntax.

Screenshots

image

As you can see, VS Code inserts the right type of comment when JSX is selected:

image

Environment:

Zed 0.47.1 – /Applications/Zed.app
macOS 12.4
architecture x86_64
@adamsoutar adamsoutar added bug [core label] triage labels Jul 14, 2022
@as-cii as-cii mentioned this issue Aug 1, 2022
46 tasks
@JosephTLyons JosephTLyons added editor Feedback for code editing, formatting, editor iterations, etc javascript JavaScript programming language support and removed triage labels Aug 21, 2022
@maxbrunsfeld maxbrunsfeld self-assigned this Jan 19, 2023
@ForLoveOfCats
Copy link
Contributor

This should be improved in our next major release! There is still some work to be done as not all edge cases with invalid syntax are handled correctly but it should behave as expected the majority of the time

@adamsoutar
Copy link
Contributor Author

Really appreciate the improvement!

Just to add to this, there are still some decently common circumstances that cause Zed to do the wrong thing. For example,

Commenting any individual prop of a JSX element isn't correct.

image

and the same issue happens when commenting inside objects passed as JSX props.

image

@JosephTLyons JosephTLyons transferred this issue from zed-industries/community Jan 24, 2024
@JosephTLyons JosephTLyons added the tsx TypeScript JSX support label Jun 7, 2024
@ShaikRehan123
Copy link

ShaikRehan123 commented Aug 5, 2024

I wonder what's the status of this, still facing this issue on both .tsx & .jsx files

@nstlgy
Copy link

nstlgy commented Aug 10, 2024

I wonder what's the status of this, still facing this issue on both .tsx & .jsx files

This was working fine before one of the recent updates which broke it, im not sure which version of the update broke it, but its not working as intended now.

@Code-DJ
Copy link

Code-DJ commented Aug 12, 2024

I wonder what's the status of this, still facing this issue on both .tsx & .jsx files

This was working fine before one of the recent updates which broke it, im not sure which version of the update broke it, but its not working as intended now.

Yes, it was working on Zed 0.146.5. I just downgraded and verified that it works on that version.

@0xd8d
Copy link

0xd8d commented Aug 13, 2024

I'll have to downgrade as well then.

@ShaikRehan123
Copy link

Hmm, Ig I'll wait for it to fix and use vscode meanwhile. This is the only thing stopping me from using zed on react codebase.

@liukunvs
Copy link

Waiting for this fix.

@alejodelosrios
Copy link

alejodelosrios commented Aug 19, 2024

For me, a downgrade is not an option. As ShaikRehan123 says, I'll also use Vscode while this is fixed.
On the other hand, I have the same problem with comments on StyledComponents. It always comments the code like this

// Some code

And it should be like this

/* Some code */

@hedefalk
Copy link

Plus one, this must have broken with a new release. I'm on 0.149.5 5321b10 and it's just doing // in tsx.

@Code-DJ
Copy link

Code-DJ commented Aug 24, 2024

Looks like it broke because of external dependency upgrade. See #16337 (comment)

/cc @SomeoneToIgnore

@silvenon
Copy link

Seems like the two issues can be treated as duplicates. Oof, this is a really painful regression 😣

@FredM7
Copy link

FredM7 commented Aug 28, 2024

Experiencing the same thing here on the Linux version.

image

Line 73's comment toggling should have been

{/* {originalWord} */}

Zed 0.149.6 on Arch Linux

@fpigeonjr
Copy link

confirmed today 😞
System Version:
macOS 14.6.1 (23G93)
Kernel Version: Darwin 23.6.0
Zed: Zed 0.150.4

@gabwill10
Copy link

gabwill10 commented Sep 2, 2024

Any update on this problem?, it's very frustrating that I can't use it just because of this.

@gabwill10
Copy link

I saw a new stable release today, and it's disappointing to see that this issue still hasn't been resolved.

@saada
Copy link

saada commented Sep 7, 2024

Looks here: https://github.com/zed-industries/zed/blob/main/crates/languages/src/tsx/config.toml#L23

The block_comment looks right. I'm not sure why it's not actually getting triggered as a line_comment instead?

@0xd8d

This comment has been minimized.

maxbrunsfeld added a commit that referenced this issue Sep 17, 2024
Fixes #5291

Release Notes:

- Fixed a bug where the 'toggle comments' command didn't use the right
comment syntax in JSX and TSX elements.

---------

Co-authored-by: Conrad <[email protected]>
Co-authored-by: Conrad Irwin <[email protected]>
Co-authored-by: Kirill Bulatov <[email protected]>
@gabwill10
Copy link

I was trying version 0.152.4 and the problem persists, I know this is already closed, I would like to ask if there is any special configuration, or if this fix goes into a new version?

@charlesszilagyi
Copy link

@gabwill10 the fix wasn't released yet

@d-strygwyr
Copy link

d-strygwyr commented Sep 24, 2024

when will this fix be released @charlesszilagyi?

@charlesszilagyi
Copy link

charlesszilagyi commented Sep 24, 2024

I know as much as you do 🤷

Actually, it seems to be in the preview release 0.154.0 (09/19/2024): https://zed.dev/releases/preview
It does seem to work 👌

noaccOS pushed a commit to noaccOS/zed that referenced this issue Oct 19, 2024
Fixes zed-industries#5291

Release Notes:

- Fixed a bug where the 'toggle comments' command didn't use the right
comment syntax in JSX and TSX elements.

---------

Co-authored-by: Conrad <[email protected]>
Co-authored-by: Conrad Irwin <[email protected]>
Co-authored-by: Kirill Bulatov <[email protected]>
@SomeoneToIgnore SomeoneToIgnore marked this as a duplicate of #18213 Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [core label] editor Feedback for code editing, formatting, editor iterations, etc javascript JavaScript programming language support tsx TypeScript JSX support
Projects
None yet
Development

Successfully merging a pull request may close this issue.