Skip to content

Commit

Permalink
Pass start_directory to new_session when building a session (#829)
Browse files Browse the repository at this point in the history
This fixes a bug introduced in 2a4714e76b3a85b3391b05413f36623bcb1493f9
(#809) whereby the `start_directory` session config was no longer passed
to the `new_session` method when building a session. This resulted in
the session working directory is not being set correctly, so new
windows/panes created in the session, would not start in the expected
directory.
  • Loading branch information
heindsight committed Oct 1, 2022
1 parent 1953ed8 commit ebffa19
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/tmuxp/workspacebuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ def build(self, session=None, append=False):
"start_directory"
]
session = self.server.new_session(
session_name=self.sconf["session_name"]
session_name=self.sconf["session_name"],
**new_session_kwargs,
)

assert self.sconf["session_name"] == session.name
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
session_name: sample_start_dir_session_path
start_directory: '/usr'
windows:
- panes:
-
22 changes: 22 additions & 0 deletions tests/test_workspacebuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,28 @@ def f():
assert retry_until(f)


@pytest.mark.skipif(
has_lt_version("3.2a"), reason="needs format introduced in tmux >= 3.2a"
)
def test_start_directory_sets_session_path(server):
yaml_config = test_utils.read_config_file(
"workspacebuilder/start_directory_session_path.yaml"
)
sconfig = kaptan.Kaptan(handler="yaml")
sconfig = sconfig.import_config(yaml_config).get()
sconfig = config.expand(sconfig)
sconfig = config.trickle(sconfig)

builder = WorkspaceBuilder(sconf=sconfig, server=server)
builder.build()

session = builder.session
expected = "{0}|/usr".format(session.id)

cmd = server.cmd("list-sessions", "-F", "#{session_id}|#{session_path}")
assert expected in cmd.stdout


def test_pane_order(session):
"""Pane ordering based on position in config and ``pane_index``.
Expand Down

0 comments on commit ebffa19

Please sign in to comment.