Skip to content

Generalize split editing from 2 to 1/2/3 panes

Mike Boyer requested to merge experimental-three-pane into main

Requested directly ("let's look at the option for 3 panes") once the 2-pane version had been confirmed solid in real use -- exactly the "generalize later, once 2 is solid" plan the original 2-pane slice laid out for itself. Built on its own branch (experimental-three-pane) rather than main, since it touches ~15 call sites and hasn't been visually confirmed in a real browser yet (no Chrome tooling available in this environment -- same caveat the original 2-pane work shipped with).

The one real design fork, scoped out before writing any code: otherPane()'s hard binary swap (pane===paneA?paneB:paneA) has no unambiguous meaning once there's more than one "other" pane. Replaced with nextPane(), which cycles through whichever panes are currently VISIBLE (paneCount-driven, not just "which pane objects exist in memory") -- at 2 panes this is byte-for-byte the old A<->B swap; at 3 panes it's A->B->C->A.

Everything else generalized cleanly, confirming the original design's own claim that it would:

  • makeResizer() and makePane() were already fully generic -- a second divider (pdragbar2/pane-b) and a third pane object (paneC) were just more calls, no changes to either helper.
  • splitOn (boolean) -> paneCount (1/2/3); toggleSplit() -> cyclePanes(), a 1->2->3->1 cycle. New shared applyPaneLayout() (called by both cyclePanes() and boot) replaces what used to be two near-duplicate show/hide/width blocks, since duplicating that dance across 2 dividers and 3 states was no longer worth it.
  • debugPane's single-global-session guard, syncSharedToolbar(), and bindPaneEvents() needed NO changes at all -- they were already pane-object-generic, never pane-count-specific.
  • openFile()'s "already open in another pane" warning now checks every VISIBLE pane except the current one, not just nextPane() -- with 3 panes a file could collide with either of the two others, not just the cycle's next stop.
  • toggleSyntax()'s fetchTokens/renderDecor calls and reloadTouchedTabs() (from the Find-in-Files Replace All work) extended to cover pane-c.

Tests (test_client_js.js): nextPane() checked directly at both paneCount values, Ctrl+Click end-to-end at 1/2/3 panes (including specifically B->C at 3 panes, not just A<->B, to prove the cycle isn't just a hardcoded pair), cyclePanes()'s full 1->2->3->1 walk, the second resizer as a real drag against the actual mouse handlers, and the original inline-width-leak regression test re-verified with a third pane in the mix rather than assumed to still hold. Full 8-file suite passes. Also verified structurally against the real running server (curl confirming #pane-c/#pdragbar2/cyclePanes() are actually served).

NOTES/multi-pane-editing.md and CLAUDE.md updated. README.md deliberately left untouched, matching how the original 2-pane work was never added there either while still experimental/unconfirmed.

Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com

Merge request reports