zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
48.61k stars 2.91k forks source link

Comment shortcut is not correct in JSX #5291

Closed adamsoutar closed 1 month ago

adamsoutar commented 2 years ago

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
ForLoveOfCats commented 1 year ago

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 commented 1 year ago

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
ShaikRehan123 commented 2 months ago

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

nstlgy commented 2 months ago

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 commented 2 months ago

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.

DaniumX commented 2 months ago

I'll have to downgrade as well then.

ShaikRehan123 commented 2 months ago

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 commented 2 months ago

Waiting for this fix.

alejodelosrios commented 2 months ago

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 commented 1 month ago

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

Code-DJ commented 1 month ago

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

/cc @SomeoneToIgnore

silvenon commented 1 month ago

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

FredM7 commented 1 month ago

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 commented 1 month ago

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

gabwill10 commented 1 month ago

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

gabwill10 commented 1 month ago

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

saada commented 1 month ago

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?

DaniumX commented 1 month ago

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

gabwill10 commented 1 month ago

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 commented 1 month ago

@gabwill10 the fix wasn't released yet

d-string commented 3 weeks ago

when will this fix be released @charlesszilagyi?

charlesszilagyi commented 3 weeks ago

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 👌