fix(layouts): duplicate layout definition error (#1792)

* fix(layouts): error on duplicate definitions

* style(fmt): rustfmt
This commit is contained in:
Aram Drevekenin 2022-10-12 14:29:36 +02:00 committed by GitHub
parent 2e5aaeb739
commit 536e0b7ca5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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