aboutsummaryrefslogtreecommitdiffstats
path: root/zellij-utils/src/kdl/kdl_layout_parser.rs
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2022-10-12 14:29:36 +0200
committerGitHub <noreply@github.com>2022-10-12 14:29:36 +0200
commit536e0b7ca51eddeb01237852137af18e90d88ef2 (patch)
tree3fbc4e4b03d279366aa98041da3c641236cebc28 /zellij-utils/src/kdl/kdl_layout_parser.rs
parentdocs(changelog): move item to the right place (diff)
downloadsl0ppij-536e0b7ca51eddeb01237852137af18e90d88ef2.tar.gz
sl0ppij-536e0b7ca51eddeb01237852137af18e90d88ef2.tar.xz
sl0ppij-536e0b7ca51eddeb01237852137af18e90d88ef2.zip
fix(layouts): duplicate layout definition error (#1792)
* fix(layouts): error on duplicate definitions * style(fmt): rustfmt
Diffstat (limited to 'zellij-utils/src/kdl/kdl_layout_parser.rs')
-rw-r--r--zellij-utils/src/kdl/kdl_layout_parser.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/zellij-utils/src/kdl/kdl_layout_parser.rs b/zellij-utils/src/kdl/kdl_layout_parser.rs
index 8824e44e..7261fecb 100644
--- a/zellij-utils/src/kdl/kdl_layout_parser.rs
+++ b/zellij-utils/src/kdl/kdl_layout_parser.rs
@@ -588,6 +588,23 @@ impl<'a> KdlLayoutParser<'a> {
kdl_node.span().len(),
))?;
self.assert_legal_node_name(&template_name, kdl_node)?;
+ if self.tab_templates.contains_key(&template_name) {
+ return Err(ConfigError::new_kdl_error(
+ format!(
+ "Duplicate definition of the \"{}\" tab_template",
+ template_name
+ ),
+ kdl_node.span().offset(),
+ kdl_node.span().len(),
+ ));
+ }
+ if self.pane_templates.contains_key(&template_name) {
+ return Err(ConfigError::new_kdl_error(
+ format!("There is already a pane_template with the name \"{}\" - can't have a tab_template with the same name", template_name),
+ kdl_node.span().offset(),
+ kdl_node.span().len(),
+ ));
+ }
self.tab_templates.insert(
template_name,
(self.parse_tab_template_node(kdl_node)?, kdl_node.clone()),
@@ -675,6 +692,16 @@ impl<'a> KdlLayoutParser<'a> {
)?;
let mut template_children = HashSet::new();
self.get_pane_template_dependencies(child, &mut template_children)?;
+ if dependency_tree.contains_key(template_name) {
+ return Err(ConfigError::new_kdl_error(
+ format!(
+ "Duplicate definition of the \"{}\" pane_template",
+ template_name
+ ),
+ child.span().offset(),
+ child.span().len(),
+ ));
+ }
dependency_tree.insert(template_name, template_children);
}
}