Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow empty window name #444

Merged
merged 4 commits into from
Oct 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ $ pip install --user --upgrade --pre libtmux

- _Insert changes/features/fixes for next release here_

### Bug fixes

- `Session.new_window()`: Improve support for `window_name: ''` downstream in tmuxp (#444, credit: @trankchung)

## libtmux 0.15.7 (2022-09-23)

- Move `.coveragerc` -> `pyproject.toml` (#443)
Expand Down
4 changes: 2 additions & 2 deletions src/libtmux/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ def new_window(
window_args += (
'-F"%s"' % formats.FORMAT_SEPARATOR.join(tmux_formats),
) # output
if window_name:
window_args += ("-n%s" % window_name,)
if window_name is not None and isinstance(window_name, str):
window_args += ("-n", window_name)

window_args += (
# empty string for window_index will use the first one available
Expand Down
22 changes: 21 additions & 1 deletion tests/test_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest

from libtmux import exc
from libtmux.common import has_gte_version
from libtmux.common import has_gte_version, has_lt_version
from libtmux.pane import Pane
from libtmux.server import Server
from libtmux.session import Session
Expand Down Expand Up @@ -290,3 +290,23 @@ def test_select_layout_accepts_no_arg(server: Server, session: Session) -> None:

window = session.new_window(window_name="test_window")
window.select_layout()


@pytest.mark.skipif(
has_lt_version("3.2"), reason="needs filter introduced in tmux >= 3.2"
)
def test_empty_window_name(session: Session) -> None:
session.set_option("automatic-rename", "off")
window = session.new_window(window_name="''", attach=True)

assert window == session.attached_window
assert window.get("window_name") == "''"
tony marked this conversation as resolved.
Show resolved Hide resolved

cmd = session.cmd(
"list-windows",
"-F",
"#{window_name}",
"-f",
"#{==:#{session_name}," + session.name + "}",
)
assert "''" in cmd.stdout