Skip to content

Commit 9846ab6

Browse files
committed
fix(tests): handle style option format changes in tmux 3.2
Based on examination of tmux source code commit f03b6113 (May 2020): In tmux 3.2, style options changed from OPTIONS_TABLE_STYLE to OPTIONS_TABLE_STRING with OPTIONS_TABLE_IS_STYLE flag to support format expansion in styles. This changed how styles are stored and displayed: **tmux ≤3.1 behavior:** - Styles parsed and normalized when stored - Output uses style_tostring() which normalizes: - "bold" → "bright" - bg=default (color 8) omitted from output - Example: Input "fg=red,bg=default,bold" → Output "fg=red,bright" **tmux ≥3.2 behavior:** - Styles stored as literal strings (enables format expansion like #{...}) - Output shows the exact string that was set - Example: Input "fg=red,bg=default,bold" → Output "fg=red,bg=default,bold" References: - /home/d/study/c/tmux/commit/f03b6113 (tmux 3.2) - /home/d/study/c/tmux-3.0a/options.c:126-127 (OPTIONS_IS_STYLE → style_tostring) - /home/d/study/c/tmux-3.0a/style.c:174-245 (style_tostring implementation) - /home/d/study/c/tmux-3.0a/attributes.c:26-50 (attributes_tostring: bold→bright)
1 parent 6260ec2 commit 9846ab6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/test_options.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -577,17 +577,21 @@ def test_style_option_validation(server: Server) -> None:
577577
session = server.new_session(session_name="test")
578578

579579
# Valid style (format differs between tmux versions)
580-
# Note: when you set bg=default, tmux internally sets bg to 8 (default color)
581-
# and when converting to string, it omits the bg property entirely
580+
# tmux ≤3.1: Styles are normalized when stored (bold→bright, bg=default omitted)
581+
# tmux ≥3.2: Styles stored as strings (literal input, allows format expansion)
582582
session.set_option("status-style", "fg=red,bg=default,bold")
583583
style = session.show_option("status-style")
584584
assert isinstance(style, str)
585585
assert "fg=red" in str(style)
586-
# bg=default is NOT included in output (tmux omits it when bg is default)
587-
if has_gte_version("3.0"):
586+
587+
if has_gte_version("3.2"):
588+
# tmux 3.2+: literal string output
589+
assert "bg=default" in str(style)
588590
assert "bold" in str(style)
589591
else:
592+
# tmux <3.2: normalized output (bold→bright, bg=default omitted)
590593
assert "bright" in str(style)
594+
assert "bg=default" not in str(style)
591595

592596
# Invalid style should raise OptionError
593597
with pytest.raises(OptionError):

0 commit comments

Comments
 (0)