Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

theme_importer: Support importing themes containing comments (#3298)

Marshall Bowerscb8c534dace2
diff --git a/Cargo.lock b/Cargo.lock
index 8e2d8d7ace8..f6c9639f99a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4433,6 +4433,12 @@ dependencies = [
"wasm-bindgen",
]
+[[package]]
+name = "json_comments"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9dbbfed4e59ba9750e15ba154fdfd9329cee16ff3df539c2666b70f58cc32105"
+
[[package]]
name = "jwt"
version = "0.16.0"
@@ -9156,6 +9162,7 @@ dependencies = [
"convert_case 0.6.0",
"gpui2",
"indexmap 1.9.3",
+ "json_comments",
"log",
"rust-embed",
"serde",
diff --git a/crates/theme_importer/Cargo.toml b/crates/theme_importer/Cargo.toml
index 306cea8ecb7..b4b72be4993 100644
--- a/crates/theme_importer/Cargo.toml
+++ b/crates/theme_importer/Cargo.toml
@@ -11,6 +11,7 @@ anyhow.workspace = true
convert_case = "0.6.0"
gpui = { package = "gpui2", path = "../gpui2" }
indexmap = "1.6.2"
+json_comments = "0.2.2"
log.workspace = true
rust-embed.workspace = true
serde.workspace = true
diff --git a/crates/theme_importer/src/main.rs b/crates/theme_importer/src/main.rs
index 579b48fe1db..0c690e891c9 100644
--- a/crates/theme_importer/src/main.rs
+++ b/crates/theme_importer/src/main.rs
@@ -11,6 +11,7 @@ use std::str::FromStr;
use anyhow::{anyhow, Context, Result};
use convert_case::{Case, Casing};
use gpui::serde_json;
+use json_comments::StripComments;
use log::LevelFilter;
use serde::Deserialize;
use simplelog::SimpleLogger;
@@ -111,7 +112,8 @@ fn main() -> Result<()> {
}
};
- let vscode_theme: VsCodeTheme = serde_json::from_reader(theme_file)
+ let theme_without_comments = StripComments::new(theme_file);
+ let vscode_theme: VsCodeTheme = serde_json::from_reader(theme_without_comments)
.context(format!("failed to parse theme {theme_file_path:?}"))?;
let converter = VsCodeThemeConverter::new(vscode_theme, theme_metadata);