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

insert comma when creating newline in JSON #18509

Open
1 task done
kurtbuilds opened this issue Sep 29, 2024 · 2 comments · May be fixed by #19801
Open
1 task done

insert comma when creating newline in JSON #18509

kurtbuilds opened this issue Sep 29, 2024 · 2 comments · May be fixed by #19801
Labels
enhancement [core label] json JSON data format support

Comments

@kurtbuilds
Copy link
Contributor

Check for existing issues

  • Completed

Describe the feature

In IntelliJ, the editor understands your code edit actions and the local context. As one example, using vim mode, press "o" (for insert new line) on the last line of a JSON object will insert the newline AND also insert a comma preceding that line.

It makes it much faster and easier to edit JSON, and it'd be huge benefit for Zed to do this as well.

If applicable, add mockups / screenshots to help present your vision of the feature

No response

@kurtbuilds kurtbuilds added admin read Pending admin review enhancement [core label] triage Maintainer needs to classify the issue labels Sep 29, 2024
@kurtbuilds
Copy link
Contributor Author

Another issue is that Zed currently inserts null as the value when inserting new keys, when I would expect it to create a nested object.

Example when editing settings.json:

image image

Instead of an object, Zed creates a null value, which I then have to select, delete, create braces, and hit newline, to create the new object.

This might be a separate issue, as it depends on Zed's understanding of the jsonschema of the current document.

@notpeter
Copy link
Member

Yes, it would be nice if Zed would automatically introduce a comma when appending an additional key to the end of an object. Interestingly we already support removing an excess trailing comma automatically (prettier will remove it if format_on_save is on) and it always felt asymmetrical that Zed would remove an extra comma on save, but never add one back.

Anyways JetBrains "Smart Keys" does this by default, it'd be nifty if Zed could too.
Screenshot 2024-10-13 at 10 55 19

@notpeter notpeter added json JSON data format support and removed triage Maintainer needs to classify the issue admin read Pending admin review labels Oct 13, 2024
kurtbuilds added a commit to kurtbuilds/zed that referenced this issue Oct 26, 2024
@kurtbuilds kurtbuilds linked a pull request Oct 27, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement [core label] json JSON data format support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants