diff options
| author | user <user@clank> | 2026-08-14 16:12:17 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-14 16:12:17 +0200 |
| commit | b2d7da47ef233c8175e27309ab0f741949420283 (patch) | |
| tree | d485554f11ba14f8f5f90bc837b6616f95d2ca37 /tests | |
| parent | sl0ppty: collapsing flattens the tree instead of nesting headers (diff) | |
| download | slosh-b2d7da47ef233c8175e27309ab0f741949420283.tar.gz slosh-b2d7da47ef233c8175e27309ab0f741949420283.tar.xz slosh-b2d7da47ef233c8175e27309ab0f741949420283.zip | |
sl0ppty: a tab is laid out or it is a list, never half of each
Collapsing was a local decision: the subtree that could not fit flattened and
everything else carried on. In practice that produces a screen with a
full-height pane on the left and a stack of headers on the right, which
explains neither what just happened nor what to do about it. Seeing it is
enough to know it is wrong.
The question is now asked of the whole tab and answered once. If any node
cannot give its children their floor, every pane in the tab becomes a row and
the focused one opens below them — including the panes that would have fitted
perfectly well on their own.
That costs something real and it is worth being honest about it: a wide screen
with one cramped column now flattens entirely, where before it would have kept
the rest of the layout. The trade is that there is one collapsed state instead
of a spectrum of partial ones, and a rule you can hold in your head is worth
more here than squeezing the last working layout out of a bad size.
Mechanically this made layout simpler rather than more complex. layout_node no
longer decides anything about presentation; a node that cannot fit sets a flag
and returns. Laying out happens twice — once to ask, once to do — and the probe
is the real layout with resizing switched off rather than a second copy of the
fitting arithmetic, because two copies of "does this fit" is exactly how the
split guide and the layout would begin to disagree. The probe not resizing is
the load-bearing part: a pane it lays out normally may be a header by the time
the real pass runs, and a pane about to be collapsed must not be told a size it
will never show.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_responsive.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_responsive.py b/tests/test_responsive.py index 0e5a347..985191b 100644 --- a/tests/test_responsive.py +++ b/tests/test_responsive.py @@ -258,6 +258,41 @@ def test_a_flattened_stack_offers_no_resize_handles(): os.unlink(lay) +def test_a_tab_is_laid_out_or_it_is_a_list_never_both(): + """The whole tab flattens, not just the subtree that could not fit. + + Half a screen of panes next to half a screen of headers explains neither + what happened nor what to do about it, so it is not a state we produce. + """ + lay = nested_layout() + # min_pane tuned so the *right column* alone cannot fit while the left + # pane, on its own, comfortably could. Locally, only the right would + # collapse; globally, everything does. + conf = tempfile.NamedTemporaryFile("w", suffix=".kdl", delete=False) + conf.write("min_pane cols=24 rows=17\n") + conf.close() + with Session(SH, cols=116, rows=52, config=conf.name, layout=lay) as s: + s.settle(20) + panes = s.panes() + shown = [p for p in panes if not p["hidden"]] + hidden = [p for p in panes if p["hidden"]] + + check("exactly one pane is open", len(shown) == 1, str(panes)) + check("every other pane is a header, including the one that did fit", + len(hidden) == len(panes) - 1, str(panes)) + check("the headers all span the full width", + len({p["w"] for p in hidden}) == 1 + and hidden[0]["w"] == shown[0]["w"], + str([(p["id"], p["w"]) for p in panes])) + # The give-away for the old behaviour: a full-height pane beside a + # stack. Nothing may sit next to a header any more. + check("no pane sits beside a header", + all(p["x"] == hidden[0]["x"] for p in panes), + str([(p["id"], p["x"]) for p in panes])) + os.unlink(conf.name) + os.unlink(lay) + + if __name__ == "__main__": test_collapse() test_collapse_expand_cycle() @@ -268,4 +303,5 @@ if __name__ == "__main__": test_collapsing_flattens_the_tree() test_every_collapsed_pane_is_clickable() test_a_flattened_stack_offers_no_resize_handles() + test_a_tab_is_laid_out_or_it_is_a_list_never_both() sys.exit(report()) |
