Skip to content

Commit b839e1c

Browse files
committed
Server(fix[new_session]): -f sets client flags, not config file path
why: new-session -f calls server_client_set_flags(), setting client flags like no-output and read-only. It does not load a config file (that is the top-level tmux -f flag). Verified in cmd-new-session.c:326. what: - Rename config_file param to client_flags - Change type from StrPath to str (flags are strings, not paths) - Remove pathlib.Path wrapping in implementation - Update test to use actual client flag value
1 parent 2ef0eb2 commit b839e1c

2 files changed

Lines changed: 11 additions & 14 deletions

File tree

src/libtmux/server.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,7 +1516,7 @@ def new_session(
15161516
*args: t.Any,
15171517
detach_others: bool | None = None,
15181518
no_size: bool | None = None,
1519-
config_file: StrPath | None = None,
1519+
client_flags: str | None = None,
15201520
**kwargs: t.Any,
15211521
) -> Session:
15221522
"""Create new session, returns new :class:`Session`.
@@ -1571,8 +1571,9 @@ def new_session(
15711571
Do not set the initial window size (``-X`` flag).
15721572
15731573
.. versionadded:: 0.45
1574-
config_file : str or PathLike, optional
1575-
Specify an alternative configuration file (``-f`` flag).
1574+
client_flags : str, optional
1575+
Set client flags (``-f`` flag), e.g. ``no-output``,
1576+
``read-only``. Requires tmux 3.2+.
15761577
15771578
.. versionadded:: 0.45
15781579
@@ -1648,8 +1649,8 @@ def new_session(
16481649
if no_size:
16491650
tmux_args += ("-X",)
16501651

1651-
if config_file is not None:
1652-
tmux_args += ("-f", str(pathlib.Path(config_file).expanduser()))
1652+
if client_flags is not None:
1653+
tmux_args += ("-f", client_flags)
16531654

16541655
if session_name is not None:
16551656
tmux_args += (f"-s{session_name}",)

tests/test_server.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -908,16 +908,12 @@ def test_list_clients(server: Server) -> None:
908908
assert isinstance(result, list)
909909

910910

911-
def test_new_session_config_file(
911+
def test_new_session_client_flags(
912912
server: Server,
913-
tmp_path: pathlib.Path,
914913
) -> None:
915-
"""Test Server.new_session() with config_file flag."""
916-
conf = tmp_path / "test.conf"
917-
conf.write_text("set -g status off\n")
918-
914+
"""Test Server.new_session() with client_flags flag."""
919915
session = server.new_session(
920-
session_name="conf_test",
921-
config_file=str(conf),
916+
session_name="flags_test",
917+
client_flags="no-output",
922918
)
923-
assert session.session_name == "conf_test"
919+
assert session.session_name == "flags_test"

0 commit comments

Comments
 (0)