1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2025-04-21 18:02:37 -04:00

Fix panic on missing general config section

Fixes #8230.
This commit is contained in:
Kirill Chibisov 2024-10-11 02:23:43 +03:00 committed by GitHub
parent 5dca7a85e7
commit a2653293a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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(()),
};
@ -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());
}
}