[WIP] Bugfix/split layout is not working correctly (#33)

* [bugfix] fix options order in split-layout command
master
Ivan 3 years ago committed by GitHub
parent 48d6526b0e
commit c07add3bef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7,7 +7,7 @@ import (
"path/filepath" "path/filepath"
) )
const version = "v0.1.7" const version = "v0.1.8"
var usage = fmt.Sprintf(`Smug - tmux session manager. Version %s var usage = fmt.Sprintf(`Smug - tmux session manager. Version %s

@ -1,6 +1,7 @@
package main package main
import ( import (
"fmt"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
@ -137,13 +138,14 @@ func (smug Smug) Start(config Config, options Options, context Context) error {
return err return err
} }
for _, p := range w.Panes { for pIndex, p := range w.Panes {
paneRoot := ExpandPath(p.Root) paneRoot := ExpandPath(p.Root)
if paneRoot == "" || !filepath.IsAbs(p.Root) { if paneRoot == "" || !filepath.IsAbs(p.Root) {
paneRoot = filepath.Join(windowRoot, p.Root) paneRoot = filepath.Join(windowRoot, p.Root)
} }
newPane, err := smug.tmux.SplitWindow(window, p.Type, paneRoot) target := fmt.Sprintf("%s.%d", window, pIndex)
newPane, err := smug.tmux.SplitWindow(target, p.Type, paneRoot)
if err != nil { if err != nil {
return err return err
} }

@ -79,7 +79,7 @@ var testTable = []struct {
"tmux new -Pd -s ses -n smug_def -c root", "tmux new -Pd -s ses -n smug_def -c root",
"tmux neww -Pd -t ses: -n win1 -c root", "tmux neww -Pd -t ses: -n win1 -c root",
"tmux select-layout -t ses:win1 main-horizontal", "tmux select-layout -t ses:win1 main-horizontal",
"tmux split-window -Pd -t ses:win1 -c root -F #{pane_id} -h", "tmux split-window -Pd -h -t ses:win1.0 -c root -F #{pane_id}",
"tmux kill-window -t ses:smug_def", "tmux kill-window -t ses:smug_def",
"tmux move-window -r -s ses: -t ses:", "tmux move-window -r -s ses: -t ses:",
"tmux attach -d -t ses:win1", "tmux attach -d -t ses:win1",
@ -192,7 +192,7 @@ var testTable = []struct {
"tmux new -Pd -s ses -n smug_def -c root", "tmux new -Pd -s ses -n smug_def -c root",
"tmux neww -Pd -t ses: -n win1 -c root/win1", "tmux neww -Pd -t ses: -n win1 -c root/win1",
"tmux select-layout -t ses:win1 even-horizontal", "tmux select-layout -t ses:win1 even-horizontal",
"tmux split-window -Pd -t ses:win1 -c root/win1/pane1 -F #{pane_id} -v", "tmux split-window -Pd -v -t ses:win1.0 -c root/win1/pane1 -F #{pane_id}",
"tmux send-keys -t ses:win1.1 command1 Enter", "tmux send-keys -t ses:win1.1 command1 Enter",
"tmux kill-window -t ses:smug_def", "tmux kill-window -t ses:smug_def",
"tmux move-window -r -s ses: -t ses:", "tmux move-window -r -s ses: -t ses:",

@ -67,7 +67,7 @@ func (tmux Tmux) RenumberWindows(target string) error {
} }
func (tmux Tmux) SplitWindow(target string, splitType string, root string) (string, error) { func (tmux Tmux) SplitWindow(target string, splitType string, root string) (string, error) {
args := []string{"split-window", "-Pd", "-t", target, "-c", root, "-F", "#{pane_id}"} args := []string{"split-window", "-Pd"}
switch splitType { switch splitType {
case VSplit: case VSplit:
@ -76,6 +76,8 @@ func (tmux Tmux) SplitWindow(target string, splitType string, root string) (stri
args = append(args, "-h") args = append(args, "-h")
} }
args = append(args, []string{"-t", target, "-c", root, "-F", "#{pane_id}"}...)
cmd := exec.Command("tmux", args...) cmd := exec.Command("tmux", args...)
pane, err := tmux.commander.Exec(cmd) pane, err := tmux.commander.Exec(cmd)

Loading…
Cancel
Save