diff options
| author | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 14:19:38 +0200 |
|---|---|---|
| committer | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 14:19:38 +0200 |
| commit | 684a3c387f132fff9c5768f56de3a6677bfda1e7 (patch) | |
| tree | 42e021c490b0e53aad1eb18ef201a1e7e005287c | |
| parent | 319fee652eda9a27dfffa0a6370ef4f434927c80 (diff) | |
Add free-form descriptor adapter
| -rw-r--r-- | lua/clever_f/action_facade.lua | 10 | ||||
| -rw-r--r-- | lua/clever_f/composition_root.lua | 4 | ||||
| -rw-r--r-- | tests/run.lua | 26 |
3 files changed, 38 insertions, 2 deletions
diff --git a/lua/clever_f/action_facade.lua b/lua/clever_f/action_facade.lua index b9bb970..b732ca6 100644 --- a/lua/clever_f/action_facade.lua +++ b/lua/clever_f/action_facade.lua @@ -51,8 +51,14 @@ function ActionFacade:primary(descriptor) return outcome end -ActionFacade.invoke_primary = ActionFacade.primary -ActionFacade.start = ActionFacade.primary +function ActionFacade:invoke_descriptor(value) + local descriptor = sequence_coordinator.validate_primary_descriptor(value) + return self:primary(descriptor) +end + +ActionFacade.invoke_primary = ActionFacade.invoke_descriptor +ActionFacade.start = ActionFacade.invoke_descriptor +ActionFacade.FreeForm = ActionFacade.invoke_descriptor function ActionFacade:start_find_forward() return self:primary("f") diff --git a/lua/clever_f/composition_root.lua b/lua/clever_f/composition_root.lua index fac567d..fa38fa1 100644 --- a/lua/clever_f/composition_root.lua +++ b/lua/clever_f/composition_root.lua @@ -179,6 +179,10 @@ function CompositionRoot:facade() return root_records[self].facade end +function CompositionRoot:invoke_descriptor(value) + return self:facade():invoke_descriptor(value) +end + function M.new(options) return CompositionRoot.new(options) end diff --git a/tests/run.lua b/tests/run.lua index 6a8fc64..08771db 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -7832,6 +7832,32 @@ test("Initiating action methods supply their fixed descriptors", function() end end) +test("Free-form action adapter accepts every valid descriptor", function() + local origins = { f = 1, F = 3, t = 1, T = 3 } + for _, descriptor in ipairs({ "f", "F", "t", "T" }) do + local state = fresh_sequence_state() + local host = MemoryHost.new({ + buffer_lines = { "aaa" }, + cursor = { line = 1, byte_column = origins[descriptor] }, + input_packets = { { kind = "text", text = "a" } }, + configuration = { + mark_cursor = false, + mark_char = false, + }, + emit_movement_events = false, + }) + local root = composition_root.new({ host = host }) + local outcome = root:invoke_descriptor(descriptor) + + same(domain.ActionKind.MOVEMENT, outcome.kind, descriptor) + same( + domain.Descriptor.from_string(descriptor), + state:get_previous_descriptor("n"), + descriptor + ) + end +end) + test("ActionFacade returns typed primary action outcomes", function() fresh_sequence_state() local host = MemoryHost.new({ |
