summaryrefslogtreecommitdiff
path: root/lua/clever_f
diff options
context:
space:
mode:
Diffstat (limited to 'lua/clever_f')
-rw-r--r--lua/clever_f/feedback_service.lua35
1 files changed, 35 insertions, 0 deletions
diff --git a/lua/clever_f/feedback_service.lua b/lua/clever_f/feedback_service.lua
index 4262e1b..4d19e6d 100644
--- a/lua/clever_f/feedback_service.lua
+++ b/lua/clever_f/feedback_service.lua
@@ -673,6 +673,41 @@ function FeedbackService:primary_restoration_active(context, window)
return not has_target_overlay(record, window)
end
+function FeedbackService:build_primary_restoration(specification)
+ if type(specification) ~= "table" then
+ fail("primary feedback restoration must be a table", 2)
+ end
+ local window = specification.window
+ or service_records[self].host:read_window()
+ if not self:primary_restoration_active(specification.context, window) then
+ return nil
+ end
+ if not domain.TargetPlan.is(specification.target_plan) then
+ fail("primary feedback restoration requires an action TargetPlan", 2)
+ end
+ local action_motion_plan = specification.motion_plan
+ local search_scope = specification.search_scope
+ or (domain.ResolvedMotionPlan.is(action_motion_plan)
+ and action_motion_plan.search_scope)
+ or domain.SearchScope.BUFFER
+ local motion_plan = domain.ResolvedMotionPlan.new({
+ target_plan = specification.target_plan,
+ descriptor = specification.stored_descriptor,
+ search_scope = search_scope,
+ endpoint_policy = specification.endpoint_policy,
+ })
+ return self:build_persistent({
+ context = specification.context,
+ anchor = specification.anchor,
+ target_plan = specification.target_plan,
+ motion_plan = motion_plan,
+ descriptor = specification.stored_descriptor,
+ endpoint_policy = specification.endpoint_policy,
+ text_view = specification.text_view,
+ window = window,
+ })
+end
+
function FeedbackService:migrate_command(request)
local reason = M.command_migration_reason(request)
local record = service_records[self]