diff options
| author | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 13:37:18 +0200 |
|---|---|---|
| committer | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 13:37:18 +0200 |
| commit | e73fbb9083cdab1542dd826096e0d673989c560c (patch) | |
| tree | e88efe67f5fdc9f402b10e9ce770639fbcd435c6 | |
| parent | acf8650a0f2d823f6d388d4d787ebfec134c35b0 (diff) | |
Select fresh effective descriptors
| -rw-r--r-- | lua/clever_f/sequence_coordinator.lua | 27 | ||||
| -rw-r--r-- | tests/run.lua | 24 |
2 files changed, 48 insertions, 3 deletions
diff --git a/lua/clever_f/sequence_coordinator.lua b/lua/clever_f/sequence_coordinator.lua index 37657b2..bcb6689 100644 --- a/lua/clever_f/sequence_coordinator.lua +++ b/lua/clever_f/sequence_coordinator.lua @@ -204,6 +204,31 @@ function SequenceCoordinator:acquire_primary(descriptor, invocation) ) end +function SequenceCoordinator:fresh_primary_resolution( + initiating_descriptor, + acquisition_result, + invocation +) + initiating_descriptor = self:validate_primary_descriptor(initiating_descriptor) + if type(acquisition_result) ~= "table" + or acquisition_result.resolved ~= true + or not domain.TargetValue.is(acquisition_result.target) + or not domain.TargetPlan.is(acquisition_result.target_plan) + or not domain.ResolvedMotionPlan.is(acquisition_result.motion_plan) + then + fail("fresh primary resolution requires acquired motion plans", 2) + end + return { + kind = "fresh", + invocation = invocation, + acquisition_result = acquisition_result, + target = acquisition_result.target, + target_plan = acquisition_result.target_plan, + motion_plan = acquisition_result.motion_plan, + effective_descriptor = initiating_descriptor, + } +end + function SequenceCoordinator:resolve_acquisition(descriptor, invocation) local result = self:acquire_primary(descriptor, invocation) if type(result.has_outcome) ~= "function" then @@ -212,7 +237,7 @@ function SequenceCoordinator:resolve_acquisition(descriptor, invocation) if result:has_outcome() then return result.outcome end - return result + return self:fresh_primary_resolution(descriptor, result, invocation) end function SequenceCoordinator:primary(value) diff --git a/tests/run.lua b/tests/run.lua index 0b83ef1..22a9003 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -7210,11 +7210,13 @@ test("Acquiring primary coordination passes the pressed descriptor", function() mark_char = false, }, }) - local result = sequence_coordinator.new({ + local coordinator = sequence_coordinator.new({ host = host, state = state, transitions = transitions, - }):primary("t") + }) + local invocation = coordinator:read_primary_invocation() + local result = coordinator:acquire_primary("t", invocation) truthy(acquisition_service.AcquisitionResult.is(result)) truthy(result.resolved) @@ -7264,6 +7266,24 @@ test("Primary coordination stops on each acquisition outcome", function() end end) +test("Fresh primary resolution uses its initiating descriptor", function() + for _, pressed in ipairs({ "f", "F", "t", "T" }) do + fresh_sequence_state() + local host = MemoryHost.new({ + buffer_lines = { "aba" }, + input_packets = { { kind = "text", text = "a" } }, + configuration = { + mark_cursor = false, + mark_char = false, + }, + }) + local resolution = sequence_coordinator.new({ host = host }):primary(pressed) + same("fresh", resolution.kind) + same(domain.Descriptor.from_string(pressed), resolution.effective_descriptor) + same(resolution.effective_descriptor, resolution.motion_plan.descriptor) + end +end) + for _, item in ipairs(tests) do local ok, failure = xpcall(item.body, debug.traceback) if not ok then |
