Make theme parsing more lenient (#7154)

This PR improves the theme parsing to be a bit more lenient, allowing
things like comments and trailing commas in theme files.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-01-31 11:05:22 -05:00 committed by GitHub
parent 7cb97e57f9
commit 8c8a5ad275
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 5 additions and 2 deletions

1
Cargo.lock generated
View File

@ -8183,6 +8183,7 @@ dependencies = [
"serde",
"serde_derive",
"serde_json",
"serde_json_lenient",
"serde_repr",
"settings",
"story",

View File

@ -120,6 +120,7 @@ schemars = "0.8"
serde = { version = "1.0", features = ["derive", "rc"] }
serde_derive = { version = "1.0", features = ["deserialize_in_place"] }
serde_json = { version = "1.0", features = ["preserve_order", "raw_value"] }
serde_json_lenient = { version = "0.1", features = ["preserve_order", "raw_value"] }
serde_repr = "0.1"
smallvec = { version = "1.6", features = ["union"] }
smol = "1.2"

View File

@ -27,7 +27,7 @@ schemars.workspace = true
serde.workspace = true
serde_derive.workspace = true
serde_json.workspace = true
serde_json_lenient = {version = "0.1", features = ["preserve_order", "raw_value"] }
serde_json_lenient.workspace = true
smallvec.workspace = true
toml.workspace = true
tree-sitter-json = "*"

View File

@ -34,6 +34,7 @@ schemars = { workspace = true, features = ["indexmap"] }
serde.workspace = true
serde_derive.workspace = true
serde_json.workspace = true
serde_json_lenient.workspace = true
serde_repr.workspace = true
settings = { path = "../settings" }
story = { path = "../story", optional = true }

View File

@ -259,7 +259,7 @@ impl ThemeRegistry {
continue;
};
let Some(theme) = serde_json::from_reader(reader).log_err() else {
let Some(theme) = serde_json_lenient::from_reader(reader).log_err() else {
continue;
};