zed icon indicating copy to clipboard operation
zed copied to clipboard

Comment shortcut is not correct in JSX

Open adamsoutar opened this issue 3 years ago • 11 comments

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 avatar Jul 14 '22 22:07 adamsoutar

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

ForLoveOfCats avatar Jan 20 '23 18:01 ForLoveOfCats

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

adamsoutar avatar May 01 '23 11:05 adamsoutar

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

adeludedperson avatar Aug 05 '24 14:08 adeludedperson

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.

nstlgy avatar Aug 10 '24 16:08 nstlgy

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.

Code-DJ avatar Aug 12 '24 15:08 Code-DJ

I'll have to downgrade as well then.

0xd8d avatar Aug 13 '24 18:08 0xd8d

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.

adeludedperson avatar Aug 13 '24 19:08 adeludedperson

Waiting for this fix.

liukunvs avatar Aug 16 '24 02:08 liukunvs

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 */

alejodelosrios avatar Aug 19 '24 15:08 alejodelosrios

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

hedefalk avatar Aug 24 '24 16:08 hedefalk

Looks like it broke because of external dependency upgrade. See https://github.com/zed-industries/zed/issues/16337#issuecomment-2293231241

/cc @SomeoneToIgnore

Code-DJ avatar Aug 24 '24 16:08 Code-DJ

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

silvenon avatar Aug 26 '24 15:08 silvenon

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

FredM7 avatar Aug 28 '24 07:08 FredM7

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

fpigeonjr avatar Aug 30 '24 16:08 fpigeonjr

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

gabwill10 avatar Sep 02 '24 14:09 gabwill10

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

gabwill10 avatar Sep 05 '24 00:09 gabwill10

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?

saada avatar Sep 07 '24 20:09 saada

Another stable release about a day ago, nothing to address this issue... How is this still not fixed.

0xd8d avatar Sep 11 '24 06:09 0xd8d

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?

gabwill10 avatar Sep 17 '24 14:09 gabwill10

@gabwill10 the fix wasn't released yet

charlesszilagyi avatar Sep 17 '24 14:09 charlesszilagyi

when will this fix be released @charlesszilagyi?

d-strygwyr avatar Sep 24 '24 03:09 d-strygwyr

~~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 👌

charlesszilagyi avatar Sep 24 '24 11:09 charlesszilagyi