mirror of
https://github.com/zellij-org/zellij.git
synced 2024-12-24 17:53:36 +03:00
fix(layouts): duplicate layout definition error (#1792)
* fix(layouts): error on duplicate definitions * style(fmt): rustfmt
This commit is contained in:
parent
2e5aaeb739
commit
536e0b7ca5
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user