From 7ec26094fee806bf53f3eb253b57f3a06025c70d Mon Sep 17 00:00:00 2001 From: Jackson Moore Date: Fri, 4 Sep 2026 13:47:20 +0200 Subject: Build explicit motion plans --- lua/clever_f/sequence_coordinator.lua | 29 +++++++++++++++++++++++++++-- tests/run.lua | 25 +++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/lua/clever_f/sequence_coordinator.lua b/lua/clever_f/sequence_coordinator.lua index 7a23eab..4d64e51 100644 --- a/lua/clever_f/sequence_coordinator.lua +++ b/lua/clever_f/sequence_coordinator.lua @@ -500,11 +500,36 @@ function SequenceCoordinator:resolve_explicit(kind, resolver_method) if type(resolver[resolver_method]) ~= "function" then fail("RepeatResolver must build " .. kind .. " requests", 2) end - return { + local request = resolver[resolver_method](resolver, invocation.context) + local resolution = { kind = kind, invocation = invocation, - request = resolver[resolver_method](resolver, invocation.context), + request = request, } + if request.neutral then + return resolution + end + local target_plan, text_view, search_scope = self:build_live_target_plan( + request.target, + invocation + ) + local motion_plan = self:build_movement_plan( + target_plan, + request.descriptor, + invocation, + search_scope + ) + resolution.target = request.target + resolution.target_plan = target_plan + resolution.motion_plan = motion_plan + resolution.text_view = text_view + resolution.search_scope = search_scope + resolution.effective_descriptor = request.descriptor + resolution.first_move = coordinator_records[self].state:get_first_move( + invocation.context + ) == true + resolution.skip_destination = target_plan.kind == domain.TargetPlanKind.EMPTY + return resolution end function SequenceCoordinator:resolve_explicit_same() diff --git a/tests/run.lua b/tests/run.lua index c755c05..204a0f3 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -7768,6 +7768,31 @@ test("Explicit coordination keeps code-zero target fallback", function() end end) +test("Explicit coordination builds target and resolved motion plans", function() + local _, transitions = fresh_sequence_state() + local stored_target = target("a") + transitions:BeginAcquisition("n", "t") + transitions:CommitAcquiredTarget("n", stored_target) + local host = MemoryHost.new({ + buffer_lines = { "aA" }, + configuration = { + ignore_case = true, + search_current_line_only = true, + }, + }) + local coordinator = sequence_coordinator.new({ host = host }) + + local resolution = coordinator:repeat_opposite_direction() + + same(stored_target, resolution.target) + same(domain.CaseMode.INSENSITIVE, resolution.target_plan.case_mode) + same(resolution.target_plan, resolution.motion_plan.target_plan) + same(domain.Descriptor.TILL_BACKWARD, resolution.effective_descriptor) + same(resolution.effective_descriptor, resolution.motion_plan.descriptor) + same(domain.SearchScope.CURRENT_LINE, resolution.motion_plan.search_scope) + same(domain.EndpointPolicy.REGULAR, resolution.motion_plan.endpoint_policy) +end) + for _, item in ipairs(tests) do local ok, failure = xpcall(item.body, debug.traceback) if not ok then -- cgit v1.2.3