diff options
| author | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 10:49:27 +0200 |
|---|---|---|
| committer | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 10:49:27 +0200 |
| commit | 26e79b1a99624c43c4149bd09b047af19c615a1c (patch) | |
| tree | 007f9a1ab421bc97ee34d9c0cbdee2e090c34253 | |
| parent | 33e93f67e78d3a502401442f80ff2572ed35d5dd (diff) | |
Classify stationary TILL moves
| -rw-r--r-- | lua/clever_f/motion_executor.lua | 18 | ||||
| -rw-r--r-- | tests/run.lua | 24 |
2 files changed, 41 insertions, 1 deletions
diff --git a/lua/clever_f/motion_executor.lua b/lua/clever_f/motion_executor.lua index 9718640..b66f0b7 100644 --- a/lua/clever_f/motion_executor.lua +++ b/lua/clever_f/motion_executor.lua @@ -31,6 +31,18 @@ function M.moved_forward(origin, destination) return domain.Position.compare(destination, origin) > 0 end +function M.command_moved_forward(descriptor, origin, destination) + descriptor = domain.Descriptor.from_string(descriptor) + origin = domain.Position.coerce(origin) + destination = domain.Position.coerce(destination) + if descriptor.family == domain.Family.TILL + and domain.Position.stationary(origin, destination) + then + return false + end + return M.moved_forward(origin, destination) +end + local function copy_options(options) local result = {} for key, value in pairs(options or {}) do @@ -147,7 +159,11 @@ function MotionExecutor:_execute_command(request) if not outcome.complete then return domain.ActionOutcome.from_search(outcome, request.plan.descriptor) end - request.moved_forward = M.moved_forward(origin, outcome.endpoint) + request.moved_forward = M.command_moved_forward( + request.plan.descriptor, + origin, + outcome.endpoint + ) return domain.ActionOutcome.from_search(outcome, request.plan.descriptor) end diff --git a/tests/run.lua b/tests/run.lua index dd0da6f..2b1613c 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -3245,6 +3245,30 @@ test("Complete command direction compares destination with saved origin", functi falsy(motion_executor.moved_forward(origin, origin)) end) +test("A stationary first TILL completion is not forward movement", function() + local origin = domain.Position.new(1, 1) + falsy(motion_executor.command_moved_forward("t", origin, origin)) + + local host = MemoryHost.new({ + buffer_lines = { "ab" }, + cursor = origin, + }) + local plan = motion_plan.build( + target_plan.build(target("b"), matching_policy()), + "t" + ) + local outcome = motion_executor.new(host):execute( + text_topology.from_host(host), + "n", + plan, + 1, + true + ) + same(domain.ActionKind.MOVEMENT, outcome.kind) + same(origin, outcome.position) + same(1, outcome.successful_steps) +end) + for _, item in ipairs(tests) do local ok, failure = xpcall(item.body, debug.traceback) if not ok then |
