Allow comments in setting and keymap JSON files
This commit is contained in:
parent
066e572767
commit
3a28f09979
10 changed files with 47 additions and 18 deletions
|
@ -9,13 +9,13 @@ use schemars::{
|
|||
},
|
||||
JsonSchema,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use serde::{de::DeserializeOwned, Deserialize};
|
||||
use serde_json::Value;
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
use theme::{Theme, ThemeRegistry};
|
||||
use util::ResultExt as _;
|
||||
|
||||
pub use keymap_file::KeymapFile;
|
||||
pub use keymap_file::KeymapFileContent;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Settings {
|
||||
|
@ -260,3 +260,9 @@ fn merge_option<T: Copy>(target: &mut Option<T>, value: Option<T>) {
|
|||
*target = value;
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parse_json_with_comments<T: DeserializeOwned>(content: &str) -> Result<T> {
|
||||
Ok(serde_json::from_reader(
|
||||
json_comments::CommentSettings::c_style().strip_comments(content.as_bytes()),
|
||||
)?)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue