szn

Bug 287 — cmdBreakPane / cmdJoinPane orphan the pane on failure after extraction

287. cmdBreakPane / cmdJoinPane orphan the pane on failure after extraction

File: src/cmd/cmd.zig:364–374, src/cmd/cmd.zig:404–406 Severity: MEDIUM Status: ✅ FIXED — cmdJoinPane now splits the destination window first (the fallible step), stows the pane in a pre-allocated placeholder window so it is never orphaned, and on splitPane failure restores the original layout via undoSplit (which also re-attaches the source window’s surviving panes if the only source window was about to be dropped). cmdBreakPane likewise creates the new window before extracting. Regression test: a split-window failure after a join-pane -h leaves no orphaned pane and the session’s pane count is unchanged.

Both commands call extractPane first, then a fallible operation (newWindow / splitPane). If the fallible step fails (OOM), the extracted pane is in no window’s list but its pty child keeps running and its master fd stays in the poll set. cmdJoinPane is worse: it may kill src_win at lines 366–372 before the failing splitPane, leaving sp orphaned after its window is gone.