summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lua/clever_f/feedback_service.lua6
-rw-r--r--tests/run.lua28
2 files changed, 34 insertions, 0 deletions
diff --git a/lua/clever_f/feedback_service.lua b/lua/clever_f/feedback_service.lua
index b6552ef..9703502 100644
--- a/lua/clever_f/feedback_service.lua
+++ b/lua/clever_f/feedback_service.lua
@@ -324,11 +324,17 @@ function FeedbackService:build_persistent(specification)
if specification.motion_plan.target_plan ~= specification.target_plan then
fail("persistent feedback must reuse the movement TargetPlan", 2)
end
+ local descriptor = specification.descriptor
+ or specification.motion_plan.descriptor
+ local endpoint_policy = specification.endpoint_policy
+ or specification.motion_plan.endpoint_policy
return {
context = context,
anchor = domain.Position.coerce(specification.anchor),
target_plan = specification.target_plan,
motion_plan = specification.motion_plan,
+ descriptor = domain.Descriptor.from_string(descriptor),
+ endpoint_policy = domain.EndpointPolicy.from_string(endpoint_policy),
window = specification.window,
}
end
diff --git a/tests/run.lua b/tests/run.lua
index 8c66ca3..57f4988 100644
--- a/tests/run.lua
+++ b/tests/run.lua
@@ -5844,6 +5844,34 @@ test("Persistent feedback reuses the movement TargetPlan", function()
end, "reuse the movement TargetPlan")
end)
+test("Persistent feedback uses its selected descriptor and endpoint policy", function()
+ fresh_sequence_state()
+ local feedback = feedback_service.new(MemoryHost.new())
+ local shared_target = target_plan.build(target("a"), matching_policy())
+ local movement = motion_plan.build(shared_target, "f")
+ local inherited = feedback:build_persistent({
+ context = "n",
+ anchor = domain.Position.new(1, 1),
+ target_plan = shared_target,
+ motion_plan = movement,
+ window = "window-1",
+ })
+ same(domain.Descriptor.FIND_FORWARD, inherited.descriptor)
+ same(domain.EndpointPolicy.REGULAR, inherited.endpoint_policy)
+
+ local selected = feedback:build_persistent({
+ context = "v",
+ anchor = domain.Position.new(1, 1),
+ target_plan = shared_target,
+ motion_plan = movement,
+ descriptor = "T",
+ endpoint_policy = domain.EndpointPolicy.VISUAL_EXCLUSIVE,
+ window = "window-1",
+ })
+ same(domain.Descriptor.TILL_BACKWARD, selected.descriptor)
+ same(domain.EndpointPolicy.VISUAL_EXCLUSIVE, selected.endpoint_policy)
+end)
+
for _, item in ipairs(tests) do
local ok, failure = xpcall(item.body, debug.traceback)
if not ok then