diff options
| author | sl0p <sl0p@sl0p.foo> | 2026-08-14 00:28:57 +0200 |
|---|---|---|
| committer | sl0p <sl0p@sl0p.foo> | 2026-08-14 00:28:57 +0200 |
| commit | 61ac1318eaad46363235d41e9cbc31eb7e3e2f84 (patch) | |
| tree | ef9b88ec45dbb7227ad15736f80aa22c3354c6ab /tests/test_split_ux.py | |
| parent | sl0ptty: the border is the button — click an edge to split toward it (diff) | |
| download | slosh-61ac1318eaad46363235d41e9cbc31eb7e3e2f84.tar.gz slosh-61ac1318eaad46363235d41e9cbc31eb7e3e2f84.tar.xz slosh-61ac1318eaad46363235d41e9cbc31eb7e3e2f84.zip | |
sl0ptty: fix the split guide describing the layout from before the split
Which border the pointer is over was remembered from the last motion event, so
after a click split the guide stayed attached to the old pane and the old edge
until the mouse moved and corrected it.
It is derived during the paint now: draw_split_guide asks the hit list where
the pointer is, using the entries that same pass just registered for that pane.
Drawing and hit-testing already could not disagree; now drawing and the layout
cannot either. The pointer position is the only thing kept.
Same lesson as the hit list, one level up: do not remember what you can derive
from the frame you are drawing.
Regression test splits by clicking a border and then deliberately does not move
the mouse, asserting exactly one pane shows a guide, that it is the pane the
pointer is actually inside, and that it is on the edge the pointer is on.
391 checks green.
Diffstat (limited to 'tests/test_split_ux.py')
| -rw-r--r-- | tests/test_split_ux.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_split_ux.py b/tests/test_split_ux.py index c394ffe..8009ee6 100644 --- a/tests/test_split_ux.py +++ b/tests/test_split_ux.py @@ -106,6 +106,41 @@ def test_the_guide(): repr(snap.screen()[:200])) +def test_guide_follows_the_new_layout(): + """Regression: the guide described the layout from *before* the split. + + Hover state used to be remembered from the last motion event, so after a + click split the guide stayed attached to the old pane and the old edge + until the mouse moved and corrected it. It is derived during the paint + now, from the rects that paint registered. + """ + with Session(SH, cols=54, rows=12) as s: + s.settle() + p = s.pane() + edge_x, edge_y = p["x"] + p["w"] - 1, p["y"] + 3 + + hover(s, edge_x, edge_y) + s.settle(60) + click(s, edge_x, edge_y) + s.settle(100) # and deliberately no further mouse movement + + snap = s.snapshot() + panes = s.panes() + check("the split happened", len(panes) == 2, str(len(panes))) + + armed = [q for q in panes + if "┃" in "".join(row[q["x"]:q["x"] + q["w"]] for row in snap.text)] + check("exactly one pane shows a guide", len(armed) == 1, str(armed)) + if len(armed) != 1: + return + check("and it is the one the pointer is actually over", + armed[0]["x"] <= edge_x < armed[0]["x"] + armed[0]["w"], + f"pointer at {edge_x}, guide on {armed[0]['x']}..{armed[0]['x'] + armed[0]['w']}") + check("on the edge the pointer is on", + snap.hit_at(edge_x, edge_y) == f"border:{armed[0]['id']}:r", + str(snap.hit_at(edge_x, edge_y))) + + def test_guide_is_per_pane(): with Session(SH, cols=90, rows=14) as s: s.settle() @@ -168,6 +203,7 @@ if __name__ == "__main__": test_no_more_plus() test_each_border_splits_toward_itself() test_the_guide() + test_guide_follows_the_new_layout() test_guide_is_per_pane() test_drag_still_moves() test_tiny_panes_have_no_targets() |
