diff --git a/tests/fixtures/workspace/builder/regression_send_keys_with_hyphen_t_00915.yaml b/tests/fixtures/workspace/builder/regression_send_keys_with_hyphen_t_00915.yaml new file mode 100644 index 00000000000..748e107e5e1 --- /dev/null +++ b/tests/fixtures/workspace/builder/regression_send_keys_with_hyphen_t_00915.yaml @@ -0,0 +1,12 @@ +# regression https://github.com/tmux-python/tmuxp/issues/915 +session_name: target hyphen regression 915 +windows: + - window_name: target hyphen regression 915 + layout: tiled + panes: + - shell_command: + - echo "t - This echo's correctly." + - shell_command: + - echo "-a - This also echo's correctly." + - shell_command: + - echo "-t - This is never sent to the pane and instead printed to the current shell." diff --git a/tests/workspace/test_builder.py b/tests/workspace/test_builder.py index 875861f0f9b..0f91325a38c 100644 --- a/tests/workspace/test_builder.py +++ b/tests/workspace/test_builder.py @@ -316,6 +316,57 @@ def test_window_options( w.select_layout(wconf["layout"]) +def test_regression_00915_pane_with_hyphen_t_target( + tmp_path: pathlib.Path, + server: "Server", + capsys: pytest.CaptureFixture[str], +) -> None: + """Regression test for send_keys in pane starting with -t.""" + yaml_config = ( + FIXTURE_PATH + / "workspace/builder" + / "regression_send_keys_with_hyphen_t_00915.yaml" + ) + workspace = ConfigReader._from_file(yaml_config) + workspace = loader.expand(workspace) + + builder = WorkspaceBuilder(session_config=workspace, server=server) + + # Create a session using the template + builder.build() + # Then append the template again + builder.build(builder.session, append=True) + + session = builder.session + assert session is not None + + # Check the panes added when created the session + pane_1 = session.windows[0].panes[0] + assert "t - This echo's correctly." in pane_1.cmd("capture-pane", "-p").stdout[0] + pane_2 = session.windows[0].panes[1] + assert ( + "-a - This also echo's correctly." in pane_2.cmd("capture-pane", "-p").stdout[0] + ) + pane_3 = session.windows[0].panes[2] + assert ( + "-t - This is never sent to the pane and instead printed to the current shell." + in pane_3.cmd("capture-pane", "-p").stdout[0] + ) + + # Check the panes in the appended window + pane_1 = session.windows[1].panes[0] + assert "t - This echo's correctly." in pane_1.cmd("capture-pane", "-p").stdout[0] + pane_2 = session.windows[1].panes[1] + assert ( + "-a - This also echo's correctly." in pane_2.cmd("capture-pane", "-p").stdout[0] + ) + pane_3 = session.windows[1].panes[2] + assert ( + "-t - This is never sent to the pane and instead printed to the current shell." + in pane_3.cmd("capture-pane", "-p").stdout[0] + ) + + @pytest.mark.flaky(reruns=5) def test_window_options_after( session: Session,