Skip to content

Fix automatic rename #774

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

Merged
merged 3 commits into from
May 21, 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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ windows:
automatic-rename: on
panes:
- shell_command:
- cmd: sh
- cmd: man ls
start_directory: '~'
- shell_command:
- cmd: echo "hey"
Expand Down
29 changes: 14 additions & 15 deletions tests/test_workspacebuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import libtmux
from libtmux import Window
from libtmux.common import has_gte_version
from libtmux.test import retry, temp_session
from libtmux.test import retry, retry_until, temp_session
from tmuxp import config, exc
from tmuxp.cli.load import load_plugins
from tmuxp.workspacebuilder import WorkspaceBuilder
Expand Down Expand Up @@ -359,6 +359,12 @@ def test_automatic_rename_option(session):
sconfig = kaptan.Kaptan(handler="yaml")
sconfig = sconfig.import_config(yaml_config).get()

# This should be a command guaranteed to be terminal name across systems
portable_command = sconfig["windows"][0]["panes"][0]["shell_command"][0]["cmd"]
# If a command is like "man ls", get the command base name, "ls"
if " " in portable_command:
portable_command = portable_command.split(" ")[0]

builder = WorkspaceBuilder(sconf=sconfig)

window_count = len(session._windows) # current window count
Expand All @@ -380,31 +386,24 @@ def test_automatic_rename_option(session):
assert s.name != "tmuxp"
w = s.windows[0]

while retry():
def check_window_name_mismatch() -> bool:
session.server._update_windows()
if w.name != "sh":
break
return w.name != portable_command

assert w.name != "sh"
assert retry_until(check_window_name_mismatch, 2, interval=0.25)

pane_base_index = w.show_window_option("pane-base-index", g=True)
w.select_pane(pane_base_index)

while retry():
def check_window_name_match() -> bool:
session.server._update_windows()
if w.name == "sh":
break
return w.name == portable_command

assert w.name == "sh"
assert retry_until(check_window_name_match, 2, interval=0.25)

w.select_pane("-D")

while retry():
session.server._update_windows()
if w["window_name"] != "sh":
break

assert w.name != "sh"
assert retry_until(check_window_name_mismatch, 2, interval=0.25)


def test_blank_pane_count(session):
Expand Down