@@ -1414,6 +1414,62 @@ func TestSimulation_HeldMotionDiagonal(t *testing.T) {
14141414 sim .waitMode (domain .ModeIdle )
14151415}
14161416
1417+ // TestSimulation_HeldMotionDropsTheGridSelection pins that a held-key glide
1418+ // leaves the click where the cursor went, not on the region the grid had
1419+ // selected: select a region, glide away from it, click.
1420+ func TestSimulation_HeldMotionDropsTheGridSelection (t * testing.T ) {
1421+ cfg := simConfig ()
1422+ cfg .HeldRepeat .Enabled = true
1423+
1424+ sim := newSimHarness (t , cfg , nil )
1425+
1426+ sim .pressHotkey (recursiveGridHotkey )
1427+ sim .waitMode (domain .ModeRecursiveGrid )
1428+
1429+ sim .waitFor ("recursive grid drawn" , func () bool {
1430+ _ , ok := sim .overlay .lastRecursiveGridBounds ()
1431+
1432+ return ok
1433+ })
1434+
1435+ movesBefore := sim .cursor .moveCount ()
1436+
1437+ // "r" selects the top-left cell, which moves the cursor onto its center.
1438+ sim .press ("r" )
1439+
1440+ sim .waitFor ("cursor moved onto the selected region" , func () bool {
1441+ return sim .cursor .moveCount () > movesBefore
1442+ })
1443+
1444+ selected := sim .cursor .position ()
1445+
1446+ sim .press ("Right" )
1447+
1448+ sim .waitFor ("cursor glided right" , func () bool {
1449+ return sim .cursor .position ().X > selected .X
1450+ })
1451+
1452+ sim .press ("__keyup_Right" )
1453+
1454+ sim .press ("Shift+L" ) // left_click
1455+
1456+ sim .waitFor ("click recorded" , func () bool {
1457+ return len (sim .ax .recordedClicks ()) >= 1
1458+ })
1459+
1460+ got := sim .ax .recordedClicks ()[0 ]
1461+ if got .action != action .TypeLeftClick {
1462+ t .Fatalf ("expected a left click, got %+v" , got )
1463+ }
1464+
1465+ if got .point .Y != selected .Y || got .point .X <= selected .X {
1466+ t .Fatalf ("click at %v, expected to the right of the grid selection %v" , got .point , selected )
1467+ }
1468+
1469+ sim .press ("Escape" )
1470+ sim .waitMode (domain .ModeIdle )
1471+ }
1472+
14171473// TestSimulation_DragJourney covers the drag primitives: mouse down at the
14181474// cursor, arrow-key relative movement while holding, mouse up at the new
14191475// position.
0 commit comments