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

API doesnt update settings if there are trailing commas in settings.json #19625

Closed
shanalikhan opened this issue Jan 31, 2017 · 11 comments
Closed
Assignees
Labels
config VS Code configuration, set up issues feature-request Request for new features or functionality json JSON support issues verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@shanalikhan
Copy link

Users of my Settings sync extension having problems shanalikhan/code-settings-sync#190

When they have trailing commas in settings.json , API doenst allow extension to add keys and values in settings.json file , Giving error code 4.

There should be way in code to let users know that they dont have valid JSON in settings.json file e.g trailing commas, without opening that file may be in status bar or let API to add settings in the settings.json file even it have trailing commas.

@bpasero
Copy link
Member

bpasero commented Jan 31, 2017

I think it would be nice if we would allow to edit a JSON when it has trailing commas.

/cc @sandy081

@bpasero bpasero added the config VS Code configuration, set up issues label Jan 31, 2017
@aeschli aeschli added json JSON support issues feature-request Request for new features or functionality labels Jan 31, 2017
@aeschli aeschli modified the milestones: Backlog, February 2017 Jan 31, 2017
@sandy081
Copy link
Member

@aeschli I had implemented this in Config edit service in last milestone when writing into the model. This is to ignore errors. But in this case, we write into the disk directly, so ignoring errors might not be a good idea. So how about having an option to ignore trailing comma (to json language server not sure) so that the json is still valid ?

@bpasero
Copy link
Member

bpasero commented Jan 31, 2017

Yeah, +1 for only ignoring trailing commas but not in general any error.

@aeschli
Copy link
Contributor

aeschli commented Jan 31, 2017

The json parser that we use (json.ts, our own implementation) already ignores trailing commas. It doesn't matter of the file is written to disk or not, as its our file and we read it.
I was assuming the bug is in json edit processor (without digging deeper into it) (jsonEdit.ts). Don't you use the json edit processor to modify the settings?

@sandy081
Copy link
Member

I use the json parser (json.ts) which is giving errors while parsing the json. This is pre-validation step before writing. If there are errors in parsing here, we quit (if it is writing to disk).

@aeschli
Copy link
Contributor

aeschli commented Jan 31, 2017

Ok, errors are reported, but the parser continues to parse and will report all properties.
Feel free to add an option to also not emit an error. https://github.com/microsoft/vscode/blob/master/src/vs/base/common/json.ts#L1115

@sandy081
Copy link
Member

sandy081 commented Feb 1, 2017

Sure will do. Thanks for the pointer.

@sandy081
Copy link
Member

sandy081 commented Feb 2, 2017

@aeschli Fixed it as we discussed

  • Defining a new option to allow trailing comma in json parser
  • Config edit service provides this option while parsing

@bpasero
Copy link
Member

bpasero commented Feb 2, 2017

Awesome!

@sandy081 sandy081 added the verification-needed Verification of issue is requested label Feb 21, 2017
@sandy081
Copy link
Member

To verify:

  • Have a trailing comma in the settings file
  • Try to update a setting that uses the API underlying. For eg: Toggle Word Wrap. This should succeed

@bpasero
Copy link
Member

bpasero commented Feb 22, 2017

This is a great fix!

@bpasero bpasero added the verified Verification succeeded label Feb 22, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
config VS Code configuration, set up issues feature-request Request for new features or functionality json JSON support issues verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

4 participants