aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2024-10-11 01:31:05 +0300
committerKirill Chibisov <contact@kchibisov.com>2024-10-11 02:14:34 +0300
commit58c9607edc2cc763cfb9f933ffffeed1b8fddd9c (patch)
treeb2229297a3eecb86e23b773d91551ae6fc4e2e3d
parent5dca7a85e7d8e98f8e770c17af8efb442c2277d0 (diff)
downloadalacritty-fix-no-import-migrate.tar.gz
alacritty-fix-no-import-migrate.zip
Don't panic on general section missingfix-no-import-migrate
Fixes #8230.
-rw-r--r--alacritty/src/migrate/mod.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/alacritty/src/migrate/mod.rs b/alacritty/src/migrate/mod.rs
index ffd0d4b4..58f381de 100644
--- a/alacritty/src/migrate/mod.rs
+++ b/alacritty/src/migrate/mod.rs
@@ -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());
+ }
}