Skip to content

Commit

Permalink
Merge pull request #506 from timhillgit/parse_gutterSettings
Browse files Browse the repository at this point in the history
Add parsing of gutterSettings
  • Loading branch information
Enselic committed Feb 7, 2024
2 parents 3a712ec + 22751f4 commit f665482
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
16 changes: 15 additions & 1 deletion src/highlighting/theme_load.rs
Expand Up @@ -300,7 +300,7 @@ impl ParseSettings for Theme {
_ => return Err(IncorrectSyntax),
};
let mut iter = items.into_iter();
let settings = match iter.next() {
let mut settings = match iter.next() {
Some(Settings::Object(mut obj)) => {
match obj.remove("settings") {
Some(settings) => ThemeSettings::parse_settings(settings)?,
Expand All @@ -309,6 +309,20 @@ impl ParseSettings for Theme {
}
_ => return Err(UndefinedSettings),
};
if let Some(Settings::Object(obj)) = obj.remove("gutterSettings") {
for (key, value) in obj {
let color = Color::parse_settings(value).ok();
match &key[..] {
"background" => {
settings.gutter = settings.gutter.or(color)
}
"foreground" => {
settings.gutter_foreground = settings.gutter_foreground.or(color)
}
_ => (),
}
}
}
let mut scopes = Vec::new();
for json in iter {
// TODO option to disable best effort parsing and bubble up warnings
Expand Down
20 changes: 19 additions & 1 deletion src/highlighting/theme_set.rs
Expand Up @@ -108,7 +108,25 @@ mod tests {
r: 0xc0,
g: 0xc5,
b: 0xce,
a: 0xFF,
a: 0xff,
}
);
assert_eq!(
theme.settings.gutter_foreground.unwrap(),
Color {
r: 0x65,
g: 0x73,
b: 0x7e,
a: 0xff,
}
);
assert_eq!(
theme.settings.gutter.unwrap(),
Color {
r: 0x34,
g: 0x3d,
b: 0x46,
a: 0xff,
}
);
// unreachable!();
Expand Down

0 comments on commit f665482

Please sign in to comment.