diff options
author | Kirill Chibisov <contact@kchibisov.com> | 2024-10-11 02:23:43 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-10 23:23:43 +0000 |
commit | a2653293a8e6ac5f5fb9f7e075656799d8df3488 (patch) | |
tree | b2229297a3eecb86e23b773d91551ae6fc4e2e3d | |
parent | 5dca7a85e7d8e98f8e770c17af8efb442c2277d0 (diff) | |
download | alacritty-a2653293a8e6ac5f5fb9f7e075656799d8df3488.tar.gz alacritty-a2653293a8e6ac5f5fb9f7e075656799d8df3488.zip |
Fix panic on missing general config section
Fixes #8230.
-rw-r--r-- | alacritty/src/migrate/mod.rs | 11 |
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()); + } } |