From 39394e207de59e6cfd6d92d8678d8085bbf2b90a Mon Sep 17 00:00:00 2001 From: Jackson Moore Date: Fri, 4 Sep 2026 13:39:19 +0200 Subject: Read stored primary sequence --- lua/clever_f/sequence_coordinator.lua | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'lua/clever_f') diff --git a/lua/clever_f/sequence_coordinator.lua b/lua/clever_f/sequence_coordinator.lua index 837acf5..350c026 100644 --- a/lua/clever_f/sequence_coordinator.lua +++ b/lua/clever_f/sequence_coordinator.lua @@ -261,6 +261,31 @@ function SequenceCoordinator:evaluate_repeat_timeout(invocation) } end +function SequenceCoordinator:stored_primary_resolution( + invocation, + pressed_descriptor, + timeout +) + if type(invocation) ~= "table" or not domain.ModeContext.is(invocation.context) then + fail("stored primary resolution requires invocation state", 2) + end + pressed_descriptor = self:validate_primary_descriptor(pressed_descriptor) + local state = coordinator_records[self].state + local stored_descriptor = state:get_previous_descriptor(invocation.context) + local stored_target = state:get_previous_target(invocation.context) + if stored_descriptor == nil or stored_target == nil then + fail("repeat-eligible primary state must contain descriptor and target", 2) + end + return { + kind = "repeat", + invocation = invocation, + pressed_descriptor = pressed_descriptor, + timeout = timeout, + stored_descriptor = stored_descriptor, + target = stored_target, + } +end + function SequenceCoordinator:primary(value) local descriptor = self:validate_primary_descriptor(value) local invocation = self:read_primary_invocation() @@ -284,12 +309,7 @@ function SequenceCoordinator:primary(value) end return self:resolve_acquisition(descriptor, invocation) end - return { - kind = "repeat", - invocation = invocation, - pressed_descriptor = descriptor, - timeout = timeout, - } + return self:stored_primary_resolution(invocation, descriptor, timeout) end function M.new(options) -- cgit v1.2.3