From ef7b3e5464ec0923cb5ac29b1a702c3b46ad48b7 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 14 Dec 2013 16:25:54 +0100 Subject: [PATCH] allow parsing multiple nodes from a json layout --- src/load_layout.c | 2 ++ testcases/t/213-layout-restore-simple.t | 39 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/load_layout.c b/src/load_layout.c index d31c230a..b69f8ac5 100644 --- a/src/load_layout.c +++ b/src/load_layout.c @@ -421,6 +421,8 @@ void tree_append_json(const char *filename) { #endif /* Allowing comments allows for more user-friendly layout files. */ yajl_config(hand, yajl_allow_comments, true); + /* Allow multiple values, i.e. multiple nodes to attach */ + yajl_config(hand, yajl_allow_multiple_values, true); yajl_status stat; json_node = focused; to_focus = NULL; diff --git a/testcases/t/213-layout-restore-simple.t b/testcases/t/213-layout-restore-simple.t index b10dfdf6..d681b8d6 100644 --- a/testcases/t/213-layout-restore-simple.t +++ b/testcases/t/213-layout-restore-simple.t @@ -63,6 +63,45 @@ is(@{$content[0]->{nodes}}, 2, 'node has two children'); close($fh); +################################################################################ +# two simple vsplit containers in the same file +################################################################################ + +$ws = fresh_workspace; + +@content = @{get_ws_content($ws)}; +is(@content, 0, 'no nodes on the new workspace yet'); + +($fh, $filename) = tempfile(UNLINK => 1); +print $fh <flush; +cmd "append_layout $filename"; + +does_i3_live; + +@content = @{get_ws_content($ws)}; +is(@content, 2, 'one node on the workspace now'); +is($content[0]->{layout}, 'splitv', 'first node has splitv layout'); +is(@{$content[0]->{nodes}}, 2, 'first node has two children'); +is($content[1]->{layout}, 'splitv', 'second node has splitv layout'); +is(@{$content[1]->{nodes}}, 0, 'first node has no children'); + +close($fh); + ################################################################################ # simple vsplit layout with swallow specifications ################################################################################