diff --git a/src/lib.rs b/src/lib.rs index 09a0fa2..fc098b8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -171,6 +171,9 @@ pub struct SimplificationOptions { /// If a horizontal container contain another horizontal container, join them? /// Same for vertical containers. Does NOT apply to grid container or tab containers. pub join_nested_linear_containers: bool, + + // Flatten tabs in tabs? + pub flatten_tabs_in_tabs: bool, } impl SimplificationOptions { @@ -192,6 +195,7 @@ impl SimplificationOptions { prune_single_child_containers: false, all_panes_must_have_tabs: false, join_nested_linear_containers: false, + flatten_tabs_in_tabs: false, }; } @@ -204,6 +208,7 @@ impl Default for SimplificationOptions { prune_single_child_containers: true, all_panes_must_have_tabs: false, join_nested_linear_containers: true, + flatten_tabs_in_tabs: false, } } } diff --git a/src/tiles.rs b/src/tiles.rs index 6ea752f..1a86069 100644 --- a/src/tiles.rs +++ b/src/tiles.rs @@ -461,6 +461,28 @@ impl Tiles { } } } + + if options.flatten_tabs_in_tabs { + let mut found = false; + let mut new_children = Vec::new(); + + for &child_id in container.children() { + if let Some(Tile::Container(Container::Tabs(child_tabs))) = + self.get(child_id) + { + new_children.extend(child_tabs.children.iter().copied()); + found = true; + } else { + new_children.push(child_id); + } + } + + if found { + let new_container = + self.insert_new(Tile::Container(Container::new_tabs(new_children))); + return SimplifyAction::Replace(new_container); + } + } } else { if options.join_nested_linear_containers { if let Container::Linear(parent) = container {