diff options
| author | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 10:26:22 +0200 |
|---|---|---|
| committer | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 10:26:22 +0200 |
| commit | a9ece4278ad0feb098db9027be1419121d61aca9 (patch) | |
| tree | ff88f952d2a3d8a96d286eae49d6a5e9c4d87c3a | |
| parent | ab20c92fb4025d447b41de5529c2380a668f4958 (diff) | |
Reject repeated stationary TILL destinations
| -rw-r--r-- | lua/clever_f/destination_engine.lua | 6 | ||||
| -rw-r--r-- | tests/run.lua | 57 |
2 files changed, 62 insertions, 1 deletions
diff --git a/lua/clever_f/destination_engine.lua b/lua/clever_f/destination_engine.lua index e3a7fc1..53b26fe 100644 --- a/lua/clever_f/destination_engine.lua +++ b/lua/clever_f/destination_engine.lua @@ -143,12 +143,16 @@ local function next_destination(request, origin, allow_till_equality) end end +local function till_equality_allowed(request, successful_steps) + return request.first_move and successful_steps == 0 +end + function DestinationEngine:calculate(view, origin, plan, count, first_move) local request = calculation_inputs(view, origin, plan, count, first_move) local destination = next_destination( request, request.origin, - request.first_move + till_equality_allowed(request, 0) ) if destination == nil then return domain.SearchOutcome.boundary_before_any(request.origin) diff --git a/tests/run.lua b/tests/run.lua index fc89801..6d9289e 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -2655,6 +2655,63 @@ test("First TILL moves accept an adjacent stationary destination", function() same(1, backward_outcome.successful_steps) end) +test("Later TILL moves skip an adjacent stationary destination", function() + local engine = destination_engine.new() + local forward_view = text_topology.new({ "abxb" }, "utf-8") + local forward_origin = domain.Position.new(1, 1) + local forward = motion_plan.build( + target_plan.build(target("b"), matching_policy()), + "t" + ) + same( + forward_origin, + engine:calculate( + forward_view, + forward_origin, + forward, + 1, + true + ).endpoint + ) + same( + domain.Position.new(1, 3), + engine:calculate( + forward_view, + forward_origin, + forward, + 1, + false + ).endpoint + ) + + local backward_view = text_topology.new({ "bxba" }, "utf-8") + local backward_origin = domain.Position.new(1, 4) + local backward = motion_plan.build( + target_plan.build(target("b"), matching_policy()), + "T" + ) + same( + backward_origin, + engine:calculate( + backward_view, + backward_origin, + backward, + 1, + true + ).endpoint + ) + same( + domain.Position.new(1, 2), + engine:calculate( + backward_view, + backward_origin, + backward, + 1, + false + ).endpoint + ) +end) + for _, item in ipairs(tests) do local ok, failure = xpcall(item.body, debug.traceback) if not ok then |
