Skip to content

Commit 4e6878b

Browse files
committed
ControlMode(capture): Trim trailing whitespace-only lines from capture_pane output
why: Control mode returns viewport-sized blank lines; align capture-pane output with subprocess expectations. what: - Drop trailing whitespace-only lines in Pane.capture_pane output - Lint/format/type/tests remain green
1 parent f29e68e commit 4e6878b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/libtmux/pane.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,11 @@ def capture_pane(
349349
cmd.extend(["-S", str(start)])
350350
if end is not None:
351351
cmd.extend(["-E", str(end)])
352-
return self.cmd(*cmd).stdout
352+
output = self.cmd(*cmd).stdout
353+
# Control mode (and tmux in general) can include viewport-sized blank lines.
354+
while output and output[-1].strip() == "":
355+
output.pop()
356+
return output
353357

354358
def send_keys(
355359
self,

0 commit comments

Comments
 (0)