Skip to content

Commit 6bd8a62

Browse files
committed
Pane(fix[capture_pane]): -M captures mode screen, not escape markup
why: capture-pane -M captures from the mode screen (e.g. copy mode), not escape markup. Verified in cmd-capture-pane.c:132 and tmux CHANGES: "Add -M flag to capture-pane to use the copy mode screen." what: - Rename escape_markup param to mode_screen - Update docstring and warning message - Update test name and parameter usage
1 parent bb4145c commit 6bd8a62

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

src/libtmux/pane.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ def capture_pane(
328328
trim_trailing: bool = False,
329329
alternate_screen: bool = False,
330330
quiet: bool = False,
331-
escape_markup: bool = False,
331+
mode_screen: bool = False,
332332
) -> list[str]:
333333
r"""Capture text from pane.
334334
@@ -384,8 +384,9 @@ def capture_pane(
384384
Default: False
385385
386386
.. versionadded:: 0.45
387-
escape_markup : bool, optional
388-
Escape markup in the output (``-M`` flag). Requires tmux 3.6+.
387+
mode_screen : bool, optional
388+
Capture from the mode screen (e.g. copy mode) instead of the
389+
pane (``-M`` flag). Requires tmux 3.6+.
389390
Default: False
390391
391392
.. versionadded:: 0.45
@@ -440,12 +441,12 @@ def capture_pane(
440441
cmd.append("-a")
441442
if quiet:
442443
cmd.append("-q")
443-
if escape_markup:
444+
if mode_screen:
444445
if has_gte_version("3.6", tmux_bin=self.server.tmux_bin):
445446
cmd.append("-M")
446447
else:
447448
warnings.warn(
448-
"escape_markup requires tmux 3.6+, ignoring",
449+
"mode_screen requires tmux 3.6+, ignoring",
449450
stacklevel=2,
450451
)
451452
return self.cmd(*cmd).stdout

tests/test_pane_capture_pane.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,8 @@ def test_capture_pane_alternate_screen(session: Session) -> None:
492492
assert isinstance(result, list)
493493

494494

495-
def test_capture_pane_escape_markup(session: Session) -> None:
496-
"""Test capture_pane with escape_markup flag (3.6+)."""
495+
def test_capture_pane_mode_screen(session: Session) -> None:
496+
"""Test capture_pane with mode_screen flag (3.6+)."""
497497
from libtmux.common import has_gte_version
498498

499499
if not has_gte_version("3.6"):
@@ -502,5 +502,5 @@ def test_capture_pane_escape_markup(session: Session) -> None:
502502
pane = session.active_window.active_pane
503503
assert pane is not None
504504

505-
result = pane.capture_pane(escape_markup=True)
505+
result = pane.capture_pane(mode_screen=True)
506506
assert isinstance(result, list)

0 commit comments

Comments
 (0)