summaryrefslogtreecommitdiff
path: root/lua/clever_f
diff options
context:
space:
mode:
Diffstat (limited to 'lua/clever_f')
-rw-r--r--lua/clever_f/motion_executor.lua23
1 files changed, 22 insertions, 1 deletions
diff --git a/lua/clever_f/motion_executor.lua b/lua/clever_f/motion_executor.lua
index cc3cc56..72a66bd 100644
--- a/lua/clever_f/motion_executor.lua
+++ b/lua/clever_f/motion_executor.lua
@@ -1,6 +1,7 @@
local destination_engine = require("clever_f.destination_engine")
local domain = require("clever_f.domain")
local sequence_state = require("clever_f.sequence_state")
+local state_transitions = require("clever_f.state_transitions")
local text_topology = require("clever_f.text_topology")
local M = {}
@@ -105,6 +106,16 @@ local function require_state(state)
return state
end
+local function require_transitions(transitions, state)
+ transitions = transitions or state_transitions.new(state)
+ if type(transitions) ~= "table"
+ or type(transitions.CommitCommandSuccess) ~= "function"
+ then
+ fail("MotionExecutor transitions must commit command success", 3)
+ end
+ return transitions
+end
+
local executor_metatable = {
__index = MotionExecutor,
__newindex = function()
@@ -123,6 +134,7 @@ function MotionExecutor.new(options, dependencies)
end
local executor = setmetatable({}, executor_metatable)
+ local state = require_state(options.state)
executor_records[executor] = {
host = require_host(options.host),
destination_engine = require_destination_engine(
@@ -131,7 +143,11 @@ function MotionExecutor.new(options, dependencies)
feedback_service = require_feedback_service(
options.feedback_service or options.feedback
),
- state = require_state(options.state),
+ state = state,
+ transitions = require_transitions(
+ options.transitions or options.state_transitions,
+ state
+ ),
}
return executor
end
@@ -208,6 +224,11 @@ function MotionExecutor:_execute_command(request)
outcome.endpoint
)
migrate_command_feedback(self, request, origin, outcome)
+ executor_records[self].transitions:CommitCommandSuccess(
+ request.context,
+ outcome.endpoint,
+ request.moved_forward
+ )
return domain.ActionOutcome.from_search(outcome, request.plan.descriptor)
end