mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-19 02:17:35 +03:00
theme_importer: Make VS Code theme parsing more lenient (#7292)
This PR updates the `theme_importer` to use `serde_json_lenient` to parse VS Code themes. This should allow us to parse themes that have trailing commas and such, in addition to the comment support that we already had. Release Notes: - N/A
This commit is contained in:
parent
3995c22414
commit
5360c0ea28
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -3867,12 +3867,6 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "json_comments"
|
|
||||||
version = "0.2.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "9dbbfed4e59ba9750e15ba154fdfd9329cee16ff3df539c2666b70f58cc32105"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jwt"
|
name = "jwt"
|
||||||
version = "0.16.0"
|
version = "0.16.0"
|
||||||
@ -8228,7 +8222,6 @@ dependencies = [
|
|||||||
"gpui",
|
"gpui",
|
||||||
"indexmap 1.9.3",
|
"indexmap 1.9.3",
|
||||||
"indoc",
|
"indoc",
|
||||||
"json_comments",
|
|
||||||
"log",
|
"log",
|
||||||
"palette",
|
"palette",
|
||||||
"pathfinder_color",
|
"pathfinder_color",
|
||||||
@ -8236,6 +8229,7 @@ dependencies = [
|
|||||||
"schemars",
|
"schemars",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"serde_json_lenient",
|
||||||
"simplelog",
|
"simplelog",
|
||||||
"strum",
|
"strum",
|
||||||
"theme",
|
"theme",
|
||||||
|
@ -13,7 +13,6 @@ convert_case = "0.6.0"
|
|||||||
gpui = { path = "../gpui" }
|
gpui = { path = "../gpui" }
|
||||||
indexmap = { version = "1.6.2", features = ["serde"] }
|
indexmap = { version = "1.6.2", features = ["serde"] }
|
||||||
indoc.workspace = true
|
indoc.workspace = true
|
||||||
json_comments = "0.2.2"
|
|
||||||
log.workspace = true
|
log.workspace = true
|
||||||
palette = { version = "0.7.3", default-features = false, features = ["std"] }
|
palette = { version = "0.7.3", default-features = false, features = ["std"] }
|
||||||
pathfinder_color = "0.5"
|
pathfinder_color = "0.5"
|
||||||
@ -21,6 +20,7 @@ rust-embed.workspace = true
|
|||||||
schemars = { workspace = true, features = ["indexmap"] }
|
schemars = { workspace = true, features = ["indexmap"] }
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
|
serde_json_lenient.workspace = true
|
||||||
simplelog = "0.9"
|
simplelog = "0.9"
|
||||||
strum = { version = "0.25.0", features = ["derive"] }
|
strum = { version = "0.25.0", features = ["derive"] }
|
||||||
theme = { path = "../theme" }
|
theme = { path = "../theme" }
|
||||||
|
@ -9,7 +9,6 @@ use std::path::PathBuf;
|
|||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
use json_comments::StripComments;
|
|
||||||
use log::LevelFilter;
|
use log::LevelFilter;
|
||||||
use schemars::schema_for;
|
use schemars::schema_for;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
@ -132,8 +131,7 @@ fn main() -> Result<()> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let theme_without_comments = StripComments::new(theme_file);
|
let vscode_theme: VsCodeTheme = serde_json_lenient::from_reader(theme_file)
|
||||||
let vscode_theme: VsCodeTheme = serde_json::from_reader(theme_without_comments)
|
|
||||||
.context(format!("failed to parse theme {theme_file_path:?}"))?;
|
.context(format!("failed to parse theme {theme_file_path:?}"))?;
|
||||||
|
|
||||||
let theme_metadata = ThemeMetadata {
|
let theme_metadata = ThemeMetadata {
|
||||||
|
Loading…
Reference in New Issue
Block a user