Skip to content

Commit

Permalink
fix: Allow empty window name in tmuxp (#444)
Browse files Browse the repository at this point in the history
#445 will address and additional issue where formats of empty
strings are potentially being filtered out as if they held no value.

In re: tmux-python/tmuxp#822
  • Loading branch information
tony authored Oct 2, 2022
2 parents f148a86 + 7fdb3f3 commit bd15984
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
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") == "''"

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

0 comments on commit bd15984

Please sign in to comment.