Skip to content

Commit

Permalink
Don't panic on general section missing
Browse files Browse the repository at this point in the history
  • Loading branch information
kchibisov committed Oct 10, 2024
1 parent 5dca7a8 commit 58c9607
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion alacritty/src/migrate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ fn migrate_imports(
recursion_limit: usize,
) -> Result<(), String> {
// Check if any imports need to be processed.
let imports = match document["general"].get("import").and_then(|i| i.as_array()) {
let imports = match document
.get("general")
.and_then(|general| general.get("import"))
.and_then(|import| import.as_array())
{
Some(array) if !array.is_empty() => array,
_ => return Ok(()),
};
Expand Down Expand Up @@ -315,4 +319,9 @@ root_value = 3

assert_eq!(output, expected);
}

#[test]
fn migrate_empty() {
assert!(migrate_toml(String::new()).unwrap().to_string().is_empty());
}
}

0 comments on commit 58c9607

Please sign in to comment.