Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps): bump toml from 0.5.10 to 0.6.0 #5656

Merged
merged 4 commits into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 55 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion helix-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ hashbrown = { version = "0.13.2", features = ["raw"] }
log = "0.4"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
toml = "0.5"
toml = "0.6"

imara-diff = "0.1.0"

Expand Down
4 changes: 2 additions & 2 deletions helix-core/tests/indent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ fn test_treesitter_indent(file_name: &str, lang_scope: &str) {

let mut config_file = test_dir;
config_file.push("languages.toml");
let config = std::fs::read(config_file).unwrap();
let config = toml::from_slice(&config).unwrap();
let config = std::fs::read_to_string(config_file).unwrap();
let config = toml::from_str(&config).unwrap();
let loader = Loader::new(config);

// set runtime path so we can find the queries
Expand Down
2 changes: 1 addition & 1 deletion helix-loader/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ path = "src/main.rs"
[dependencies]
anyhow = "1"
serde = { version = "1.0", features = ["derive"] }
toml = "0.5"
toml = "0.6"
etcetera = "0.4"
tree-sitter = "0.20"
once_cell = "1.17"
Expand Down
2 changes: 1 addition & 1 deletion helix-term/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pulldown-cmark = { version = "0.9", default-features = false }
content_inspector = "0.2.4"

# config
toml = "0.5"
toml = "0.6"

serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion helix-term/src/keymap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl<'de> serde::de::Visitor<'de> for KeyTrieVisitor {
S: serde::de::SeqAccess<'de>,
{
let mut commands = Vec::new();
while let Some(command) = seq.next_element::<&str>()? {
while let Some(command) = seq.next_element::<String>()? {
commands.push(
command
.parse::<MappableCommand>()
Expand Down
2 changes: 1 addition & 1 deletion helix-view/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ chardetng = "0.1"

serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
toml = "0.5"
toml = "0.6"
log = "~0.4"

which = "4.4"
Expand Down
84 changes: 41 additions & 43 deletions helix-view/src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
str,
};

use anyhow::{anyhow, Context, Result};
use anyhow::{anyhow, Result};
use helix_core::hashmap;
use helix_loader::merge_toml_values;
use log::warn;
Expand Down Expand Up @@ -209,16 +209,18 @@ pub struct Theme {

impl From<Value> for Theme {
fn from(value: Value) -> Self {
let values: Result<HashMap<String, Value>> =
toml::from_str(&value.to_string()).context("Failed to load theme");

let (styles, scopes, highlights) = build_theme_values(values);

Self {
styles,
scopes,
highlights,
..Default::default()
if let Value::Table(table) = value {
let (styles, scopes, highlights) = build_theme_values(table);

Self {
styles,
scopes,
highlights,
..Default::default()
}
} else {
warn!("Expected theme TOML value to be a table, found {:?}", value);
Default::default()
}
}
}
Expand All @@ -228,9 +230,9 @@ impl<'de> Deserialize<'de> for Theme {
where
D: Deserializer<'de>,
{
let values = HashMap::<String, Value>::deserialize(deserializer)?;
let values = Map::<String, Value>::deserialize(deserializer)?;

let (styles, scopes, highlights) = build_theme_values(Ok(values));
let (styles, scopes, highlights) = build_theme_values(values);

Ok(Self {
styles,
Expand All @@ -242,39 +244,37 @@ impl<'de> Deserialize<'de> for Theme {
}

fn build_theme_values(
values: Result<HashMap<String, Value>>,
mut values: Map<String, Value>,
) -> (HashMap<String, Style>, Vec<String>, Vec<Style>) {
let mut styles = HashMap::new();
let mut scopes = Vec::new();
let mut highlights = Vec::new();

if let Ok(mut colors) = values {
// TODO: alert user of parsing failures in editor
let palette = colors
.remove("palette")
.map(|value| {
ThemePalette::try_from(value).unwrap_or_else(|err| {
warn!("{}", err);
ThemePalette::default()
})
})
.unwrap_or_default();
// remove inherits from value to prevent errors
let _ = colors.remove("inherits");
styles.reserve(colors.len());
scopes.reserve(colors.len());
highlights.reserve(colors.len());
for (name, style_value) in colors {
let mut style = Style::default();
if let Err(err) = palette.parse_style(&mut style, style_value) {
// TODO: alert user of parsing failures in editor
let palette = values
.remove("palette")
.map(|value| {
ThemePalette::try_from(value).unwrap_or_else(|err| {
warn!("{}", err);
}

// these are used both as UI and as highlights
styles.insert(name.clone(), style);
scopes.push(name);
highlights.push(style);
ThemePalette::default()
})
})
.unwrap_or_default();
// remove inherits from value to prevent errors
let _ = values.remove("inherits");
styles.reserve(values.len());
scopes.reserve(values.len());
highlights.reserve(values.len());
for (name, style_value) in values {
let mut style = Style::default();
if let Err(err) = palette.parse_style(&mut style, style_value) {
warn!("{}", err);
}

// these are used both as UI and as highlights
styles.insert(name.clone(), style);
scopes.push(name);
highlights.push(style);
}

(styles, scopes, highlights)
Expand Down Expand Up @@ -517,10 +517,8 @@ mod tests {

let mut style = Style::default();
let palette = ThemePalette::default();
if let Value::Table(entries) = table {
for (_name, value) in entries {
palette.parse_style(&mut style, value).unwrap();
}
for (_name, value) in table {
palette.parse_style(&mut style, value).unwrap();
}

assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion xtask/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ helix-term = { version = "0.6", path = "../helix-term" }
helix-core = { version = "0.6", path = "../helix-core" }
helix-view = { version = "0.6", path = "../helix-view" }
helix-loader = { version = "0.6", path = "../helix-loader" }
toml = "0.5"
toml = "0.6"