1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-18 13:55:23 -05:00

Don't panic on general section missing

Fixes #8230.
This commit is contained in:
Kirill Chibisov 2024-10-11 01:31:05 +03:00
parent 5dca7a85e7
commit 58c9607edc
No known key found for this signature in database
GPG key ID: E803FF4B6CE71BCB

View file

@ -134,7 +134,11 @@ fn migrate_imports(
recursion_limit: usize, recursion_limit: usize,
) -> Result<(), String> { ) -> Result<(), String> {
// Check if any imports need to be processed. // 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, Some(array) if !array.is_empty() => array,
_ => return Ok(()), _ => return Ok(()),
}; };
@ -315,4 +319,9 @@ root_value = 3
assert_eq!(output, expected); assert_eq!(output, expected);
} }
#[test]
fn migrate_empty() {
assert!(migrate_toml(String::new()).unwrap().to_string().is_empty());
}
} }