Skip to content

Commit 3eef36e

Browse files
committed
fix(ControlMode): handle -P flag output with % prefix correctly
Root Cause: - tmux pane IDs use format %N (like %0, %1, %2, %3) - When split-window -P -F#{pane_id} outputs "%3", it's sent INSIDE the %begin/%end command block - But because it starts with %, the protocol parser treated it as a control message/notification, NOT as stdout content - Result: pane_cmd.stdout was empty, causing IndexError The Fix: - Modified _handle_percent_line() to check parser state - When IN_COMMAND state, lines starting with % that aren't known control messages (%begin, %end, %error) are now treated as stdout - This correctly captures pane/window/session IDs from -P flag Impact: - Fixed 62 of 82 test failures (76% reduction) - Before: 82 failed, 512 passed - After: 20 failed, 574 passed - All split/resize/pane operations now work correctly Remaining Issues: - capture-pane -p still has issues (different root cause) - Environment variable passing needs investigation - Session name validation edge cases - Some doctests need updates Verification: Confirmed with debug logging that %3␞ was being sent inside command block but incorrectly routed to notification handler instead of stdout. Related: #605
1 parent 8257caa commit 3eef36e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/libtmux/_internal/engines/control_protocol.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ def _handle_percent_line(self, line: str) -> None:
188188
self._on_begin(parts)
189189
elif tag in ("%end", "%error"):
190190
self._on_end_or_error(tag, parts)
191+
elif self.state is ParserState.IN_COMMAND and self._current:
192+
# Inside a command block, lines starting with % that aren't
193+
# control messages (begin/end/error) are likely tmux identifiers
194+
# (pane IDs like %3, window IDs like @2, etc.) from -P flag output
195+
# Treat them as stdout content, not notifications
196+
self._current.stdout.append(line)
191197
else:
192198
self._on_notification(line, parts)
193199

0 commit comments

Comments
 (0)