Skip to content

Commit ebffa19

Browse files
authored
Pass start_directory to new_session when building a session (#829)
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.
1 parent 1953ed8 commit ebffa19

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

src/tmuxp/workspacebuilder.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ def build(self, session=None, append=False):
214214
"start_directory"
215215
]
216216
session = self.server.new_session(
217-
session_name=self.sconf["session_name"]
217+
session_name=self.sconf["session_name"],
218+
**new_session_kwargs,
218219
)
219220

220221
assert self.sconf["session_name"] == session.name
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
session_name: sample_start_dir_session_path
3+
start_directory: '/usr'
4+
windows:
5+
- panes:
6+
-

tests/test_workspacebuilder.py

+22
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,28 @@ def f():
514514
assert retry_until(f)
515515

516516

517+
@pytest.mark.skipif(
518+
has_lt_version("3.2a"), reason="needs format introduced in tmux >= 3.2a"
519+
)
520+
def test_start_directory_sets_session_path(server):
521+
yaml_config = test_utils.read_config_file(
522+
"workspacebuilder/start_directory_session_path.yaml"
523+
)
524+
sconfig = kaptan.Kaptan(handler="yaml")
525+
sconfig = sconfig.import_config(yaml_config).get()
526+
sconfig = config.expand(sconfig)
527+
sconfig = config.trickle(sconfig)
528+
529+
builder = WorkspaceBuilder(sconf=sconfig, server=server)
530+
builder.build()
531+
532+
session = builder.session
533+
expected = "{0}|/usr".format(session.id)
534+
535+
cmd = server.cmd("list-sessions", "-F", "#{session_id}|#{session_path}")
536+
assert expected in cmd.stdout
537+
538+
517539
def test_pane_order(session):
518540
"""Pane ordering based on position in config and ``pane_index``.
519541

0 commit comments

Comments
 (0)