Skip to content

Commit cb8c534

Browse files
authored
theme_importer: Support importing themes containing comments (#3298)
This PR updates the `theme_importer` with support for parsing theme files containing comments. Up until now we've been manually removing comments from the VS Code theme files. Release Notes: - N/A
1 parent 6bc1cf0 commit cb8c534

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/theme_importer/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ anyhow.workspace = true
1111
convert_case = "0.6.0"
1212
gpui = { package = "gpui2", path = "../gpui2" }
1313
indexmap = "1.6.2"
14+
json_comments = "0.2.2"
1415
log.workspace = true
1516
rust-embed.workspace = true
1617
serde.workspace = true

crates/theme_importer/src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use std::str::FromStr;
1111
use anyhow::{anyhow, Context, Result};
1212
use convert_case::{Case, Casing};
1313
use gpui::serde_json;
14+
use json_comments::StripComments;
1415
use log::LevelFilter;
1516
use serde::Deserialize;
1617
use simplelog::SimpleLogger;
@@ -111,7 +112,8 @@ fn main() -> Result<()> {
111112
}
112113
};
113114

114-
let vscode_theme: VsCodeTheme = serde_json::from_reader(theme_file)
115+
let theme_without_comments = StripComments::new(theme_file);
116+
let vscode_theme: VsCodeTheme = serde_json::from_reader(theme_without_comments)
115117
.context(format!("failed to parse theme {theme_file_path:?}"))?;
116118

117119
let converter = VsCodeThemeConverter::new(vscode_theme, theme_metadata);

0 commit comments

Comments
 (0)