summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackson Moore <jacksonmoore@tuta.io>2026-09-04 10:48:22 +0200
committerJackson Moore <jacksonmoore@tuta.io>2026-09-04 10:48:22 +0200
commitecddf5c243a63d08b8c595ace160128c279e03b6 (patch)
tree929830bd25a22f5cfaef0eb1e44f1acf8f9bddae
parent3770a731f500e9253bbcf300c213276359a15686 (diff)
Apply reached command endpoints
-rw-r--r--lua/clever_f/motion_executor.lua6
-rw-r--r--tests/run.lua20
2 files changed, 25 insertions, 1 deletions
diff --git a/lua/clever_f/motion_executor.lua b/lua/clever_f/motion_executor.lua
index 5dba08f..0c49ce1 100644
--- a/lua/clever_f/motion_executor.lua
+++ b/lua/clever_f/motion_executor.lua
@@ -54,8 +54,9 @@ end
local function require_host(host)
if type(host) ~= "table"
or type(host.read_cursor) ~= "function"
+ or type(host.apply_cursor) ~= "function"
then
- fail("MotionExecutor host must provide read_cursor", 3)
+ fail("MotionExecutor host must provide cursor movement", 3)
end
return host
end
@@ -134,6 +135,9 @@ function MotionExecutor:_execute_command(request)
local host = executor_records[self].host
local origin = host:read_cursor()
local outcome = calculate(self, request, origin)
+ if outcome.successful_steps > 0 then
+ host:apply_cursor(outcome.endpoint)
+ end
return domain.ActionOutcome.from_search(outcome, request.plan.descriptor)
end
diff --git a/tests/run.lua b/tests/run.lua
index 938d21a..65d831b 100644
--- a/tests/run.lua
+++ b/tests/run.lua
@@ -3173,6 +3173,26 @@ test("Command execution saves its origin before destination calculation", functi
same(domain.Position.new(1, 1), outcome.position)
end)
+test("Command execution applies the last reached count endpoint", function()
+ local host = MemoryHost.new({
+ buffer_lines = { "axaxa" },
+ cursor = { line = 1, byte_column = 1 },
+ })
+ local view = text_topology.from_host(host)
+ local executor = motion_executor.new(host)
+ local plan = motion_plan.build(
+ target_plan.build(target("a"), matching_policy()),
+ "f"
+ )
+
+ local outcome = executor:execute(view, "n", plan, 3, true)
+ same(domain.ActionKind.FAILED_SEARCH, outcome.kind)
+ same(domain.SearchStatus.BOUNDARY_AFTER_PARTIAL, outcome.search_outcome.status)
+ same(2, outcome.successful_steps)
+ same(domain.Position.new(1, 5), host:read_cursor())
+ same(domain.Position.new(1, 5), outcome.position)
+end)
+
for _, item in ipairs(tests) do
local ok, failure = xpcall(item.body, debug.traceback)
if not ok then