summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lua/clever_f/sequence_coordinator.lua9
-rw-r--r--tests/run.lua20
2 files changed, 29 insertions, 0 deletions
diff --git a/lua/clever_f/sequence_coordinator.lua b/lua/clever_f/sequence_coordinator.lua
index 350c026..f5e8a95 100644
--- a/lua/clever_f/sequence_coordinator.lua
+++ b/lua/clever_f/sequence_coordinator.lua
@@ -276,6 +276,14 @@ function SequenceCoordinator:stored_primary_resolution(
if stored_descriptor == nil or stored_target == nil then
fail("repeat-eligible primary state must contain descriptor and target", 2)
end
+ local resolver = coordinator_records[self].repeat_resolver
+ if type(resolver.resolve_primary_direction) ~= "function" then
+ fail("SequenceCoordinator repeat resolver must resolve primary direction", 2)
+ end
+ local effective_descriptor = resolver:resolve_primary_direction(
+ stored_descriptor,
+ pressed_descriptor
+ )
return {
kind = "repeat",
invocation = invocation,
@@ -283,6 +291,7 @@ function SequenceCoordinator:stored_primary_resolution(
timeout = timeout,
stored_descriptor = stored_descriptor,
target = stored_target,
+ effective_descriptor = effective_descriptor,
}
end
diff --git a/tests/run.lua b/tests/run.lua
index 6186d7b..d9fcf26 100644
--- a/tests/run.lua
+++ b/tests/run.lua
@@ -7400,6 +7400,26 @@ test("Timely primary repetition reads current-context sequence values", function
same(domain.Descriptor.TILL_FORWARD, resolution.pressed_descriptor)
end)
+test("Timely primary repetition resolves live effective direction", function()
+ local _, transitions = fresh_sequence_state()
+ local landing = domain.Position.new(1, 3)
+ transitions:BeginAcquisition("n", "F")
+ transitions:CommitAcquiredTarget("n", target("a"))
+ transitions:CommitCommandSuccess("n", landing, false)
+ local host = MemoryHost.new({
+ buffer_lines = { "ababa" },
+ cursor = landing,
+ configuration = { fix_key_direction = false },
+ })
+ local coordinator = sequence_coordinator.new({ host = host })
+
+ local relative = coordinator:primary("f")
+ same(domain.Descriptor.FIND_BACKWARD, relative.effective_descriptor)
+ host:set_configuration("fix_key_direction", true)
+ local fixed = coordinator:primary("f")
+ same(domain.Descriptor.FIND_FORWARD, fixed.effective_descriptor)
+end)
+
for _, item in ipairs(tests) do
local ok, failure = xpcall(item.body, debug.traceback)
if not ok then