From 2481b9dcd73e91969033abb2b6f83aed608aeea1 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sun, 1 Sep 2013 13:35:04 +0200 Subject: [PATCH] =?UTF-8?q?Bugfix:=20don=E2=80=99t=20flatten=20tabbed/stac?= =?UTF-8?q?ked=20containers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #1053 --- src/tree.c | 2 ++ testcases/t/145-flattening.t | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/tree.c b/src/tree.c index 6d23750f..58af674b 100644 --- a/src/tree.c +++ b/src/tree.c @@ -702,6 +702,8 @@ void tree_flatten(Con *con) { * the con’s parent to be redundant */ if (!con_is_split(con) || !con_is_split(child) || + (con->layout != L_SPLITH && con->layout != L_SPLITV) || + (child->layout != L_SPLITH && child->layout != L_SPLITV) || con_orientation(con) == con_orientation(child) || con_orientation(child) != con_orientation(parent)) goto recurse; diff --git a/testcases/t/145-flattening.t b/testcases/t/145-flattening.t index 33d9f1d1..2ccf4539 100644 --- a/testcases/t/145-flattening.t +++ b/testcases/t/145-flattening.t @@ -38,4 +38,38 @@ my $ws = get_ws($tmp); is($ws->{layout}, 'splith', 'workspace layout is splith'); is(@{$ws->{nodes}}, 3, 'all three windows on workspace level'); +################################################################################ +# Ticket #1053 provides a sequence of operations where the flattening does not +# work correctly: +################################################################################ + +$tmp = fresh_workspace; + +my $tab1 = open_window; +my $tab2 = open_window; +$mid = open_window; +$right = open_window; +cmd 'focus right'; +cmd 'split v'; +cmd 'focus right'; +cmd 'move left'; +cmd 'layout tabbed'; +cmd 'focus parent'; +cmd 'split v'; + +$ws = get_ws($tmp); +my @nodes = @{$ws->{nodes}}; +is(@nodes, 3, 'all three windows on workspace level'); +is($nodes[0]->{layout}, 'splitv', 'first node is splitv'); +is(@{$nodes[0]->{nodes}}, 1, 'one node in the first node'); +is($nodes[0]->{nodes}->[0]->{layout}, 'tabbed', 'tabbed layout'); +is(@{$nodes[0]->{nodes}->[0]->{nodes}}, 2, 'two nodes in that node'); + +cmd 'focus right'; +cmd 'move left'; + +$ws = get_ws($tmp); +@nodes = @{$ws->{nodes}}; +is(@nodes, 2, 'all three windows on workspace level'); + done_testing;