diff options
author | Aram Drevekenin <aram@poor.dev> | 2022-10-20 18:09:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-20 18:09:23 +0200 |
commit | ebc4222d6af7734e346dcf00442422cadfe5cdf6 (patch) | |
tree | 5f701099e01f2f37afb69503a594bf4163b18e68 /zellij-client/src | |
parent | 27c875b5684a4166b6e86063302daf4c97408948 (diff) |
fix(layouts): do not override explicitly set layout if it exists (#1830)
Diffstat (limited to 'zellij-client/src')
-rw-r--r-- | zellij-client/src/old_config_converter/convert_old_yaml_files.rs | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/zellij-client/src/old_config_converter/convert_old_yaml_files.rs b/zellij-client/src/old_config_converter/convert_old_yaml_files.rs index 0d5bf2e52..346b6eb62 100644 --- a/zellij-client/src/old_config_converter/convert_old_yaml_files.rs +++ b/zellij-client/src/old_config_converter/convert_old_yaml_files.rs @@ -270,9 +270,20 @@ fn convert_yaml( let mut new_config_file = yaml_config_file.clone(); new_config_file.set_extension("kdl"); let yaml_config_file_exists = yaml_config_file.exists(); - let layout_was_explicitly_set = layout_files_to_convert + let explicitly_set_layout_file = layout_files_to_convert .iter() - .find(|(_l, was_explicitly_set)| *was_explicitly_set) + .find(|(_l, was_explicitly_set)| *was_explicitly_set); + let layout_was_explicitly_set = explicitly_set_layout_file.is_some(); + let explicitly_set_layout_files_kdl_equivalent_exists = explicitly_set_layout_file + .map(|(layout_file, _)| { + let mut layout_file = layout_file.clone(); + layout_file.set_extension("kdl"); + if layout_file.exists() { + Some(true) + } else { + None + } + }) .is_some(); let new_config_file_exists = new_config_file.exists(); let no_need_to_convert_config = @@ -307,6 +318,17 @@ fn convert_yaml( new_config_file.as_path().as_os_str().to_string_lossy().to_string() ) ); + } else if layout_was_explicitly_set && explicitly_set_layout_files_kdl_equivalent_exists { + let explicitly_set_layout_file = explicitly_set_layout_file.unwrap().0.clone(); + let mut explicitly_set_layout_file_kdl_equivalent = explicitly_set_layout_file.clone(); + explicitly_set_layout_file_kdl_equivalent.set_extension("kdl"); + return Err( + format!( + "Specified old YAML format layout (--layout {}) but a new KDL file exists in that location. To fix, point to it the new file instead: zellij --layout {}", + explicitly_set_layout_file.display(), + explicitly_set_layout_file_kdl_equivalent.display() + ) + ); } if !layout_files_to_convert.is_empty() { print_conversion_layouts_message(layout_files_to_convert.clone()); |