From 6c3009c5041a2e661504825f68b0a3675562a647 Mon Sep 17 00:00:00 2001 From: Jackson Moore Date: Fri, 4 Sep 2026 12:46:52 +0200 Subject: Build stored-motion restoration plan --- lua/clever_f/feedback_service.lua | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'lua/clever_f') 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] -- cgit v1.2.3