settings: accept trailing commas (#2606)

Z-2357

I've found a crate that handles both comments and trailing commas in
JSON. It is a fork of `serde_json`, but it is maintained & up-to-date.
Sadly RawValue seems to not play nicely with it; I've ran into
deserialisation issues around use of RawValue. For this PR I've migrated
to `Value` API.

Obviously this is just a point of discussion, not something I'd merge
straight away. There may be better solutions to this particular problem.

I've also noticed that `serde_json_lenient` does not handle trailing
commas after bindings array. I'm not sure how big of an issue that is.

Release Notes:
- Improved handling of trailing commas in settings files.
[#1322](https://github.com/zed-industries/community/issues/1322)
This commit is contained in:
Piotr Osiewicz
2023-06-19 18:29:03 +02:00
committed by GitHub
parent 70ccbbafc1
commit 2a3c660d1f
7 changed files with 81 additions and 40 deletions
Generated
+28 -15
View File
@@ -593,7 +593,7 @@ dependencies = [
"http",
"http-body",
"hyper",
"itoa",
"itoa 1.0.6",
"matchit",
"memchr",
"mime",
@@ -3011,7 +3011,7 @@ checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482"
dependencies = [
"bytes 1.4.0",
"fnv",
"itoa",
"itoa 1.0.6",
]
[[package]]
@@ -3070,7 +3070,7 @@ dependencies = [
"http-body",
"httparse",
"httpdate",
"itoa",
"itoa 1.0.6",
"pin-project-lite 0.2.9",
"socket2",
"tokio",
@@ -3336,6 +3336,12 @@ dependencies = [
"either",
]
[[package]]
name = "itoa"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4"
[[package]]
name = "itoa"
version = "1.0.6"
@@ -3396,12 +3402,6 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "json_comments"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41ee439ee368ba4a77ac70d04f14015415af8600d6c894dc1f11bd79758c57d5"
[[package]]
name = "jwt"
version = "0.16.0"
@@ -5667,7 +5667,7 @@ dependencies = [
"bitflags",
"errno 0.2.8",
"io-lifetimes 0.5.3",
"itoa",
"itoa 1.0.6",
"libc",
"linux-raw-sys 0.0.42",
"once_cell",
@@ -6099,7 +6099,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "057d394a50403bcac12672b2b18fb387ab6d289d957dab67dd201875391e52f1"
dependencies = [
"indexmap",
"itoa",
"itoa 1.0.6",
"ryu",
"serde",
]
[[package]]
name = "serde_json_lenient"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7d7b9ce5b0a63c6269b9623ed828b39259545a6ec0d8a35d6135ad6af6232add"
dependencies = [
"indexmap",
"itoa 0.4.8",
"ryu",
"serde",
]
@@ -6122,7 +6134,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"
dependencies = [
"form_urlencoded",
"itoa",
"itoa 1.0.6",
"ryu",
"serde",
]
@@ -6148,7 +6160,7 @@ dependencies = [
"fs",
"futures 0.3.28",
"gpui",
"json_comments",
"indoc",
"lazy_static",
"postage",
"pretty_assertions",
@@ -6157,6 +6169,7 @@ dependencies = [
"serde",
"serde_derive",
"serde_json",
"serde_json_lenient",
"smallvec",
"sqlez",
"staff_mode",
@@ -6507,7 +6520,7 @@ dependencies = [
"hkdf",
"hmac 0.12.1",
"indexmap",
"itoa",
"itoa 1.0.6",
"libc",
"libsqlite3-sys",
"log",
@@ -6993,7 +7006,7 @@ version = "0.3.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f3403384eaacbca9923fa06940178ac13e4edb725486d70e8e15881d0c836cc"
dependencies = [
"itoa",
"itoa 1.0.6",
"serde",
"time-core",
"time-macros",