Skip to content
Draft
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
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ on Python 3.12 and later, exercising pre-launch observer attachment, keyboard
and bracketed-paste input, window resize redraws, and `.ambr` snapshot
assertions across tmux releases.

#### Verify picker paste state across tmux releases (#947)

The interactive picker test checks live bracketed-paste mode and one-shot
capture metadata, covering unavailable metadata on older servers alongside
reported enabled and disabled states on newer servers.

### Development

#### Prebuilt tmux setup in CI (#941)
Expand Down
7 changes: 7 additions & 0 deletions docs/api/libtmux.vt.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ styles:
>>> _ = quick_pane.send_vt_input("enter")
```

One-shot capture reports bracketed paste through
`captured.metadata.bracketed_paste_flag`. `True` means enabled and `False`
means disabled. When tmux omits the state, the flag is `None` and
`captured.completeness.unexposed_fields` includes `bracketed_paste_flag`.
On those servers, attach with {meth}`~libtmux.Pane.observe_vt` before the
application enables `?2004` to observe the mode change.

## Page through captured scrollback (`snap.viewport()`)

When `history_lines` retains primary scrollback (`None` for full history or a
Expand Down
50 changes: 27 additions & 23 deletions tests/test_vt.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,13 +614,12 @@ def test_vt_interactive_picker_lifecycle(
"""Interactive TUI lifecycle: attach, navigate, paste, resize, and exit."""
from libvt.input import KeyEvent, PasteEvent
from libvt.modes import Mode
from libvt.testing import serialize_vt_snapshot, vt_screen
from libvt.testing import vt_screen

scrubs = [
(r"(?<=Filter:) +PID=\d+", " PID=<PID>"),
(r"(?<=Filter: work) +PID=\d+", " PID=<PID>"),
]
filtered_scrubs = [(r"(?<=Filter: work) +PID=\d+", " PID=<PID>")]
win = session.new_window(
window_name="vt-picker",
window_shell=(
Expand All @@ -631,6 +630,7 @@ def test_vt_interactive_picker_lifecycle(
assert pane is not None
retry_until(lambda: "BOOT_GATE" in "\n".join(pane.capture_pane()))
win.resize(height=6, width=28)
capture_reports_paste = has_gte_version("3.7", tmux_bin=session.server.tmux_bin)

async def _exercise() -> None:
async with vt_observer(history_lines=0) as observer:
Expand Down Expand Up @@ -666,27 +666,27 @@ async def _exercise() -> None:
)
assert filtered_snap[2, 2].style.reverse is True
assert Mode.BRACKETED_PASTE in filtered_snap.modes
observed_serialized = serialize_vt_snapshot(
filtered_snap,
scrubbers=filtered_scrubs,
)
captured_serialized = serialize_vt_snapshot(
pane,
scrubbers=filtered_scrubs,
captured = pane.capture_vt(history_lines=0)
paste_flag = captured.metadata.bracketed_paste_flag
assert paste_flag is (True if capture_reports_paste else None)
assert (
"bracketed_paste_flag" in captured.completeness.unexposed_fields
) == (paste_flag is None)

captured_snap = captured.snapshot
assert (captured_snap.rows, captured_snap.cols) == (
filtered_snap.rows,
filtered_snap.cols,
)
if has_gte_version("3.7", tmux_bin=session.server.tmux_bin):
assert observed_serialized == captured_serialized
else:
# tmux < 3.7 lacks #{bracket_paste_flag}; live observation retains
# ?2004h while capture_vt matches geometry, cursor, cells, and styles.
assert (
observed_serialized.replace(
"modes=[BRACKETED_PASTE]",
"modes=[]",
1,
)
== captured_serialized
)
assert captured_snap.active_is_alt == filtered_snap.active_is_alt
assert captured_snap.cursor.row == filtered_snap.cursor.row
assert captured_snap.cursor.col == filtered_snap.cursor.col
assert captured_snap.cursor.visible == filtered_snap.cursor.visible
expected_modes = filtered_snap.modes
if paste_flag is None:
expected_modes = expected_modes - {Mode.BRACKETED_PASTE}
assert captured_snap.modes == expected_modes
assert tuple(captured_snap[:]) == tuple(filtered_snap[:])

win.resize(height=6, width=34)
resized_snap = await handle.wait_until(
Expand All @@ -700,7 +700,7 @@ async def _exercise() -> None:
resized_snap.cursor.visible,
) == (5, 33, False)
assert resized_snap[2, 2].style.reverse is True
if has_gte_version("3.7", tmux_bin=session.server.tmux_bin):
if capture_reports_paste:
assert Mode.BRACKETED_PASTE in resized_snap.modes
else:
# Native resize recapture on tmux < 3.7 omits #{bracket_paste_flag}.
Expand All @@ -719,5 +719,9 @@ async def _exercise() -> None:
assert finish_snap.cursor.visible is True
assert Mode.BRACKETED_PASTE not in finish_snap.modes
assert "selected=worker" in finish_snap.text
restored = pane.capture_vt(history_lines=0)
assert restored.metadata.bracketed_paste_flag is (
False if capture_reports_paste else None
)

asyncio.run(_exercise())
Loading