Skip to content

Commit 6ccb5c5

Browse files
committed
feat(Server.new_session): Support '-'
1 parent d5afed9 commit 6ccb5c5

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/libtmux/server.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
session_check_name,
3030
)
3131

32+
if t.TYPE_CHECKING:
33+
from typing_extensions import Literal, TypeAlias
34+
35+
DashLiteral: TypeAlias = Literal["-"]
36+
3237
logger = logging.getLogger(__name__)
3338

3439

@@ -351,8 +356,8 @@ def new_session(
351356
start_directory: t.Optional[str] = None,
352357
window_name: t.Optional[str] = None,
353358
window_command: t.Optional[str] = None,
354-
x: t.Optional[int] = None,
355-
y: t.Optional[int] = None,
359+
x: t.Optional[t.Union[int, "DashLiteral"]] = None,
360+
y: t.Optional[t.Union[int, "DashLiteral"]] = None,
356361
*args: t.Any,
357362
**kwargs: t.Any,
358363
) -> Session:
@@ -395,10 +400,10 @@ def new_session(
395400
when the command exits. NOTE: When this command exits the window
396401
will close. This feature is useful for long-running processes
397402
where the closing of the window upon completion is desired.
398-
x : int, optional
403+
x : [int, str], optional
399404
Force the specified width instead of the tmux default for a
400405
dettached session
401-
y : int, optional
406+
y : [int, str], optional
402407
Force the specified height instead of the tmux default for a
403408
dettached session
404409

tests/test_server.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,17 @@ def test_new_session_width_height(server: Server) -> None:
143143
assert pane.display_message("#{window_width}", get_text=True)[0] == "32"
144144
assert pane.display_message("#{window_height}", get_text=True)[0] == "32"
145145

146+
if has_gte_version("3.1"):
147+
my_second_session = server.new_session(
148+
"test_new_session_width_height_latest",
149+
window_command=cmd,
150+
x="-",
151+
y="-",
152+
)
153+
pane_2 = my_second_session.windows[0].panes[0]
154+
assert pane_2.display_message("#{window_height}", get_text=True)[0] == "32"
155+
assert pane_2.display_message("#{window_width}", get_text=True)[0] == "32"
156+
146157

147158
def test_no_server_sessions() -> None:
148159
server = Server(socket_name="test_attached_session_no_server")

0 commit comments

Comments
 (0)