diff options
| author | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 14:19:05 +0200 |
|---|---|---|
| committer | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 14:19:05 +0200 |
| commit | 319fee652eda9a27dfffa0a6370ef4f434927c80 (patch) | |
| tree | 2a1dd9cc88020c6d37a211aa61a97dd196486e7e | |
| parent | 5e2146af55a73b8d34596c2f28e6d7fc83a959ea (diff) | |
Add fixed initiating actions
| -rw-r--r-- | lua/clever_f/action_facade.lua | 21 | ||||
| -rw-r--r-- | lua/clever_f/composition_root.lua | 8 | ||||
| -rw-r--r-- | tests/run.lua | 32 |
3 files changed, 57 insertions, 4 deletions
diff --git a/lua/clever_f/action_facade.lua b/lua/clever_f/action_facade.lua index e8ea356..b9bb970 100644 --- a/lua/clever_f/action_facade.lua +++ b/lua/clever_f/action_facade.lua @@ -54,6 +54,27 @@ end ActionFacade.invoke_primary = ActionFacade.primary ActionFacade.start = ActionFacade.primary +function ActionFacade:start_find_forward() + return self:primary("f") +end + +function ActionFacade:start_find_backward() + return self:primary("F") +end + +function ActionFacade:start_till_forward() + return self:primary("t") +end + +function ActionFacade:start_till_backward() + return self:primary("T") +end + +ActionFacade.StartFindForward = ActionFacade.start_find_forward +ActionFacade.StartFindBackward = ActionFacade.start_find_backward +ActionFacade.StartTillForward = ActionFacade.start_till_forward +ActionFacade.StartTillBackward = ActionFacade.start_till_backward + function ActionFacade:reset() local outcome = self:coordinator():reset() if not domain.ActionOutcome.is(outcome) then diff --git a/lua/clever_f/composition_root.lua b/lua/clever_f/composition_root.lua index 83cfe96..fac567d 100644 --- a/lua/clever_f/composition_root.lua +++ b/lua/clever_f/composition_root.lua @@ -22,16 +22,16 @@ M.ACTION_NAMES = { local ACTION_INVOCATIONS = { StartFindForward = function(facade) - return facade:primary("f") + return facade:start_find_forward() end, StartFindBackward = function(facade) - return facade:primary("F") + return facade:start_find_backward() end, StartTillForward = function(facade) - return facade:primary("t") + return facade:start_till_forward() end, StartTillBackward = function(facade) - return facade:primary("T") + return facade:start_till_backward() end, Reset = function(facade) return facade:reset() diff --git a/tests/run.lua b/tests/run.lua index 403000a..6a8fc64 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -7800,6 +7800,38 @@ test("Failed resolved primary search still refreshes highlight timeout", functio truthy(host:timers()[state.highlight_timer].active) end) +test("Initiating action methods supply their fixed descriptors", function() + local cases = { + { method = "start_find_forward", descriptor = "f", origin = 1 }, + { method = "start_find_backward", descriptor = "F", origin = 3 }, + { method = "start_till_forward", descriptor = "t", origin = 1 }, + { method = "start_till_backward", descriptor = "T", origin = 3 }, + } + + for _, case in ipairs(cases) do + fresh_sequence_state() + local host = MemoryHost.new({ + buffer_lines = { "aaa" }, + cursor = { line = 1, byte_column = case.origin }, + input_packets = { { kind = "text", text = "a" } }, + configuration = { + mark_cursor = false, + mark_char = false, + }, + emit_movement_events = false, + }) + local facade = action_facade.new({ host = host }) + local outcome = facade[case.method](facade) + + same(domain.ActionKind.MOVEMENT, outcome.kind, case.method) + same( + domain.Descriptor.from_string(case.descriptor), + facade:coordinator():last_primary_resolution().effective_descriptor, + case.method + ) + end +end) + test("ActionFacade returns typed primary action outcomes", function() fresh_sequence_state() local host = MemoryHost.new({ |
