summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackson Moore <jacksonmoore@tuta.io>2026-09-04 14:14:32 +0200
committerJackson Moore <jacksonmoore@tuta.io>2026-09-04 14:14:32 +0200
commite192a496e9264249ff60b625453a3f1227af2221 (patch)
treeccac8668f16ee015190364bf1fb62fb82fc439b0
parent294d7efdf06efbaab0c68e0a2cf01185622c9241 (diff)
Fix reset action flow
-rw-r--r--lua/clever_f/action_facade.lua10
-rw-r--r--lua/clever_f/sequence_coordinator.lua13
-rw-r--r--tests/run.lua31
3 files changed, 54 insertions, 0 deletions
diff --git a/lua/clever_f/action_facade.lua b/lua/clever_f/action_facade.lua
index 1dd5052..e8ea356 100644
--- a/lua/clever_f/action_facade.lua
+++ b/lua/clever_f/action_facade.lua
@@ -54,6 +54,16 @@ end
ActionFacade.invoke_primary = ActionFacade.primary
ActionFacade.start = ActionFacade.primary
+function ActionFacade:reset()
+ local outcome = self:coordinator():reset()
+ if not domain.ActionOutcome.is(outcome) then
+ fail("SequenceCoordinator must return an ActionOutcome", 2)
+ end
+ return outcome
+end
+
+ActionFacade.Reset = ActionFacade.reset
+
local function explicit_outcome(facade, method_name)
local coordinator = facade:coordinator()
local outcome = coordinator[method_name](coordinator)
diff --git a/lua/clever_f/sequence_coordinator.lua b/lua/clever_f/sequence_coordinator.lua
index 59dc332..a83c75f 100644
--- a/lua/clever_f/sequence_coordinator.lua
+++ b/lua/clever_f/sequence_coordinator.lua
@@ -480,6 +480,19 @@ function SequenceCoordinator:last_explicit_resolution()
return coordinator_records[self].last_explicit_resolution
end
+function SequenceCoordinator:reset()
+ local record = coordinator_records[self]
+ local position = domain.Position.coerce(record.host:read_cursor())
+ local cleanup = record.transitions:PublicReset(record.host:read_window())
+ if type(record.feedback.release_transition_cleanup) ~= "function" then
+ fail("FeedbackService must release reset cleanup", 2)
+ end
+ record.feedback:release_transition_cleanup(cleanup)
+ return domain.ActionOutcome.neutral(position)
+end
+
+SequenceCoordinator.Reset = SequenceCoordinator.reset
+
function SequenceCoordinator:read_explicit_invocation()
local host = coordinator_records[self].host
if type(host) ~= "table"
diff --git a/tests/run.lua b/tests/run.lua
index fb97146..9ccb079 100644
--- a/tests/run.lua
+++ b/tests/run.lua
@@ -7707,6 +7707,37 @@ test("ActionFacade returns typed primary action outcomes", function()
end, "clever-f: Invalid mapping 'x'")
end)
+test("ActionFacade Reset applies public cleanup and returns neutral", function()
+ local state, transitions = fresh_sequence_state()
+ local target_value = target("a")
+ local landing = domain.Position.new(1, 3)
+ local host = MemoryHost.new({
+ buffer_lines = { "aba" },
+ cursor = landing,
+ })
+ transitions:BeginAcquisition("n", "f")
+ transitions:CommitAcquiredTarget("n", target_value, 25)
+ transitions:CommitCommandSuccess("n", landing, true)
+ local overlay = host:create_highlight({
+ group = "CleverFChar",
+ window = "window-1",
+ positions = { landing },
+ })
+ transitions:AddTargetOverlay(overlay, "window-1", 1)
+ local timer = host:start_timer(30, function() end)
+ transitions:SetHighlightTimer(timer)
+
+ local outcome = action_facade.new({ host = host }):reset()
+
+ same(domain.ActionKind.NEUTRAL, outcome.kind)
+ same(landing, outcome.position)
+ same(nil, state:get_previous_descriptor("n"))
+ same(nil, state:get_previous_landing("n"))
+ same(target_value, state:get_previous_target("n"))
+ same(nil, host:highlights()[overlay])
+ falsy(host:timers()[timer].active)
+end)
+
test("Same-direction explicit coordination reads current-context state", function()
local _, transitions = fresh_sequence_state()
local normal_target = target("a")