summaryrefslogtreecommitdiff
path: root/lua/clever_f
diff options
context:
space:
mode:
Diffstat (limited to 'lua/clever_f')
-rw-r--r--lua/clever_f/sequence_coordinator.lua32
1 files changed, 26 insertions, 6 deletions
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)