Skip to content

#818: Adopt quadraui SplitTree for divider geometry — 0 uses today, ~800 lines hand-rolled - #845

Merged
JDonaghy merged 2 commits into
developfrom
issue-818-adopt-quadraui-splittree-for-divider-geo
Sep 5, 2026
Merged

#818: Adopt quadraui SplitTree for divider geometry — 0 uses today, ~800 lines hand-rolled#845
JDonaghy merged 2 commits into
developfrom
issue-818-adopt-quadraui-splittree-for-divider-geo

Conversation

@JDonaghy

@JDonaghy JDonaghy commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Closes #818

Automated PR opened by coordinator for review of issue #818.

…etry

GroupLayout::calculate_group_rects/dividers and WindowLayout::calculate_rects/
dividers each re-derived the same split math in two independent hand-rolled
recursive passes over the tree — exactly the second-source-of-truth drift risk
(#582/#452) quadraui's SplitTree::layout exists to close. Both now convert to
a quadraui::SplitTree and read leaf rects + divider geometry off one layout()
call; the vimcode<->quadraui SplitDirection mapping is centralised in
to_quadraui_direction/from_quadraui_direction and reused by render.rs's
divider_to_split, which used to carry its own copy of the same match.

The render.rs hit-test/drag layer (DividerGeometry, divider_hit_test,
DividerMetrics/GTK_DIVIDER_METRICS, route_divider_grab, apply_divider_drag)
stays local: quadraui's SplitTreeLayout::hit_test_divider/hit_test_divider_cell
only support a symmetric continuous tolerance or an exact single-cell
quantized match, and can't express the asymmetric multi-cell bands vimcode's
TUI backend needs (e.g. a horizontal group divider's grabbable band is the
whole neighbouring tab-bar block, not a margin around a point). That gap is
called out in a comment at the hit-test section for a follow-up quadraui
issue rather than being papered over.

No behavior change: all existing black-box divider tests (both backends —
gtk::testing's window_split_divider_* and tui_main::shell_app's
group_divider_*_via_shell_app) pass unchanged, confirming the SplitTree
round-trip reproduces the old geometry exactly.
…ailure

Blocking finding: no new tests targeted the SplitTree migration. Adds one
black-box test per backend that a single 2-pane divider test can't cover:
a *nested* `:vsplit`-of-`:vsplit` (GTK, WindowLayout) / nested vertical
editor-group split (TUI, GroupLayout), asserting the rendered position of
each of the two painted dividers by `split_index`, then dragging only the
inner one and asserting the outer, sibling divider's painted column is
unaffected. This is the concrete shape #582/#452 warned two independently
hand-rolled recursive passes over the same tree could number or position
inconsistently — the exact risk `SplitTree::layout`'s single pass (adopted
by this issue) closes off.

Built each test by first getting the "outer"/"inner" labeling backwards
against the real tree shape (GTK's `:vsplit` nests on the *first* child,
TUI's editor-group split nests on the *second*), which briefly produced a
false failure with a good lesson: select the divider under test by
`split_index` from `SplitTree::layout`'s own pre-order numbering, never by
comparing painted x/column, since which child the nesting lands in isn't
fixed.

Honesty check per the issue's "state that new tests fail against unfixed
develop" clause: with `src/core/window.rs`/`src/render.rs` swapped back to
the pre-#818 hand-rolled two-pass code (commit f989712) and only these two
new tests re-run, both still pass. That's the expected result of a
genuinely behavior-preserving refactor (already argued algebraically in
the original commit) — #582's fix had already made the two hand-rolled
passes agree before this issue touched them, so there is no divergence
left in `develop` for a black-box test to catch red-handed. Recorded here
per the letter of the acceptance clause rather than silently skipped; the
new tests still earn their keep as regression coverage for the
`SplitTree`-based code going forward, exercising a multi-divider tree shape
neither backend had any coverage for before.

Nit: `window_id_from_widget`/`group_id_from_widget` now `panic!` with the
offending id on parse failure instead of silently falling back to id `0` —
a wrong-window bug from a future `quadraui::WidgetId` change would be far
harder to spot than a loud failure.

Not addressed here (needs the coordinator, not this branch): the
non-blocking ask to confirm a quadraui issue was filed for the
asymmetric/multi-cell divider-tolerance gap `render.rs`'s `divider_to_split`
doc comment already describes, and to confirm #818 stays open behind it.
This worker has no `gh`/GitHub access to file that issue directly — flagged
in the final report for the coordinator to file and to keep #818 open (or
explicitly re-scope it) rather than close it as fully done.
@JDonaghy
JDonaghy merged commit cc4db6b into develop Sep 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adopt quadraui SplitTree for divider geometry — 0 uses today, ~800 lines hand-rolled

1 participant