From bf1e50906e9ec3e236e7ba0f58df97987962c5e4 Mon Sep 17 00:00:00 2001 From: Ivan Date: Sat, 13 Feb 2021 15:11:09 +0200 Subject: [PATCH] Select layout after panes initialization (#40) --- smug.go | 20 ++++++++++---------- smug_test.go | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/smug.go b/smug.go index 4298924..c322bae 100644 --- a/smug.go +++ b/smug.go @@ -126,16 +126,6 @@ func (smug Smug) Start(config Config, options Options, context Context) error { } } - layout := w.Layout - if layout == "" { - layout = EvenHorizontal - } - - _, err = smug.tmux.SelectLayout(window, layout) - if err != nil { - return err - } - for _, p := range w.Panes { paneRoot := ExpandPath(p.Root) if paneRoot == "" || !filepath.IsAbs(p.Root) { @@ -154,6 +144,16 @@ func (smug Smug) Start(config Config, options Options, context Context) error { } } } + + layout := w.Layout + if layout == "" { + layout = EvenHorizontal + } + + _, err = smug.tmux.SelectLayout(window, layout) + if err != nil { + return err + } } smug.tmux.KillWindow(sessionName + defaultWindowName) diff --git a/smug_test.go b/smug_test.go index 156f580..10f5e88 100644 --- a/smug_test.go +++ b/smug_test.go @@ -78,8 +78,8 @@ var testTable = []struct { "tmux has-session -t ses:", "tmux new -Pd -s ses -n smug_def -c root", "tmux neww -Pd -t ses: -c root -F #{window_id} -n win1", - "tmux select-layout -t 1 main-horizontal", "tmux split-window -Pd -h -t 1 -c root -F #{pane_id}", + "tmux select-layout -t 1 main-horizontal", "tmux kill-window -t ses:smug_def", "tmux move-window -r -s ses: -t ses:", "tmux attach -d -t ses:win1", @@ -191,9 +191,9 @@ var testTable = []struct { "tmux has-session -t ses:", "tmux new -Pd -s ses -n smug_def -c root", "tmux neww -Pd -t ses: -c root/win1 -F #{window_id} -n win1", - "tmux select-layout -t 1 even-horizontal", "tmux split-window -Pd -v -t 1 -c root/win1/pane1 -F #{pane_id}", "tmux send-keys -t 1.1 command1 Enter", + "tmux select-layout -t 1 even-horizontal", "tmux kill-window -t ses:smug_def", "tmux move-window -r -s ses: -t ses:", "tmux attach -d -t ses:win1",