Skip to content

Commit 86c1a90

Browse files
committed
fix(compat): add tmux version compatibility for 3.2a-3.5
- Add command_error hook field (tmux 3.5+) - Guard pane-colours test with version check (tmux 3.3+) - Update terminal-overrides expectations for tmux 3.5 - Fix escape-time doctests to not rely on default value
1 parent dd0438b commit 86c1a90

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/libtmux/_internal/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,8 @@ class Hooks(
434434
after_split_window: SparseArray[str] = field(default_factory=SparseArray)
435435
# Runs after 'unbind-key' completes
436436
after_unbind_key: SparseArray[str] = field(default_factory=SparseArray)
437+
# Runs when a command fails (tmux 3.5+)
438+
command_error: SparseArray[str] = field(default_factory=SparseArray)
437439

438440
@classmethod
439441
def from_stdout(cls, value: list[str]) -> Hooks:

src/libtmux/options.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -609,9 +609,6 @@ def set_option(
609609
...
610610
... default_option_scope = OptionScope.Server
611611
612-
>>> MyServer()._show_option('escape-time')
613-
500
614-
615612
>>> MyServer().set_option('escape-time', 1250)
616613
<libtmux.options.MyServer object at ...>
617614
@@ -727,8 +724,8 @@ def unset_option(
727724
>>> MyServer().unset_option('escape-time')
728725
<libtmux.options.MyServer object at ...>
729726
730-
>>> MyServer()._show_option('escape-time')
731-
500
727+
>>> isinstance(MyServer()._show_option('escape-time'), int)
728+
True
732729
"""
733730
if scope is DEFAULT_OPTION_SCOPE:
734731
scope = self.default_option_scope

tests/test_options.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,11 @@ def test_stable_baseline_options_and_hooks(server: Server) -> None:
489489
assert terminal_features["rxvt*"] == ["ignorefkeys"]
490490

491491
# Terminal overrides differ by version
492-
if has_gte_version("3.0"):
492+
# In tmux 3.5+, terminal-overrides has a default value
493+
if has_gte_version("3.5"):
494+
terminal_overrides = server.show_option("terminal-overrides")
495+
assert isinstance(terminal_overrides, (dict, type(None)))
496+
elif has_gte_version("3.0"):
493497
assert server.show_option("terminal-overrides") is None
494498
else:
495499
terminal_overrides = server.show_option("terminal-overrides")
@@ -515,10 +519,11 @@ def test_stable_baseline_options_and_hooks(server: Server) -> None:
515519
with pytest.raises(OptionError):
516520
server.show_option("update-environment")
517521

518-
# List variables: Pane
522+
# List variables: Pane (pane-colours added in tmux 3.3)
519523
pane = session.active_pane
520524
assert pane is not None
521-
assert pane.show_option("pane-colours") is None
525+
if has_gte_version("3.3"):
526+
assert pane.show_option("pane-colours") is None
522527

523528

524529
def test_high_level_api_expectations(server: Server) -> None:

0 commit comments

Comments
 (0)