diff --git a/Cargo.lock b/Cargo.lock index 4b7791e0e3abbe..b1ba19ec318ac1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12077,7 +12077,7 @@ dependencies = [ "paths", "schemars", "serde", - "serde_json", + "serde_json_lenient", "snippet", "util", ] diff --git a/crates/snippet_provider/Cargo.toml b/crates/snippet_provider/Cargo.toml index 6bdc4bbb07209f..3e312a0923263a 100644 --- a/crates/snippet_provider/Cargo.toml +++ b/crates/snippet_provider/Cargo.toml @@ -18,7 +18,7 @@ gpui.workspace = true parking_lot.workspace = true paths.workspace = true serde.workspace = true -serde_json.workspace = true +serde_json_lenient.workspace = true snippet.workspace = true util.workspace = true schemars.workspace = true diff --git a/crates/snippet_provider/src/format.rs b/crates/snippet_provider/src/format.rs index 2a8acf0d654ff4..a52df704123593 100644 --- a/crates/snippet_provider/src/format.rs +++ b/crates/snippet_provider/src/format.rs @@ -5,7 +5,7 @@ use schemars::{ JsonSchema, }; use serde::Deserialize; -use serde_json::Value; +use serde_json_lenient::Value; #[derive(Deserialize)] pub struct VSSnippetsFile { @@ -20,7 +20,7 @@ impl VSSnippetsFile { .into_generator() .into_root_schema_for::(); - serde_json::to_value(schema).unwrap() + serde_json_lenient::to_value(schema).unwrap() } } diff --git a/crates/snippet_provider/src/lib.rs b/crates/snippet_provider/src/lib.rs index d5f3de1b647ec7..dc625779b37bc0 100644 --- a/crates/snippet_provider/src/lib.rs +++ b/crates/snippet_provider/src/lib.rs @@ -98,7 +98,8 @@ async fn process_updates( let Some(file_contents) = contents else { return; }; - let Ok(as_json) = serde_json::from_str::(&file_contents) else { + let Ok(as_json) = serde_json_lenient::from_str::(&file_contents) + else { return; }; let snippets = file_to_snippets(as_json); diff --git a/crates/snippet_provider/src/registry.rs b/crates/snippet_provider/src/registry.rs index 0abc7e84b2a203..b4b3e3282afffa 100644 --- a/crates/snippet_provider/src/registry.rs +++ b/crates/snippet_provider/src/registry.rs @@ -37,7 +37,8 @@ impl SnippetRegistry { } pub fn register_snippets(&self, file_path: &Path, contents: &str) -> Result<()> { - let snippets_in_file: crate::format::VSSnippetsFile = serde_json::from_str(contents)?; + let snippets_in_file: crate::format::VSSnippetsFile = + serde_json_lenient::from_str(contents)?; let kind = file_path .file_stem() .and_then(|stem| stem.to_str().and_then(file_stem_to_key));