summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lua/clever_f/destination_engine.lua6
-rw-r--r--tests/run.lua36
2 files changed, 42 insertions, 0 deletions
diff --git a/lua/clever_f/destination_engine.lua b/lua/clever_f/destination_engine.lua
index eb41d47..027dd2a 100644
--- a/lua/clever_f/destination_engine.lua
+++ b/lua/clever_f/destination_engine.lua
@@ -168,6 +168,12 @@ function DestinationEngine:calculate(view, origin, plan, count, first_move)
if successful_steps == request.count.value then
return domain.SearchOutcome.complete(current_origin, successful_steps)
end
+ if successful_steps > 0 then
+ return domain.SearchOutcome.boundary_after_partial(
+ current_origin,
+ successful_steps
+ )
+ end
return domain.SearchOutcome.boundary_before_any(request.origin)
end
diff --git a/tests/run.lua b/tests/run.lua
index de0013f..eac53bf 100644
--- a/tests/run.lua
+++ b/tests/run.lua
@@ -2803,6 +2803,42 @@ test("Complete outcomes report the last destination after every count unit", fun
same(2, backward_outcome.successful_steps)
end)
+test("Partial outcomes retain the last intermediate destination", function()
+ local engine = destination_engine.new()
+ local find_view = text_topology.new({ "axaxa" }, "utf-8")
+ local find_plan = motion_plan.build(
+ target_plan.build(target("a"), matching_policy()),
+ "f"
+ )
+ local find_partial = engine:calculate(
+ find_view,
+ domain.Position.new(1, 1),
+ find_plan,
+ 3,
+ true
+ )
+ same(domain.SearchStatus.BOUNDARY_AFTER_PARTIAL, find_partial.status)
+ falsy(find_partial.complete)
+ same(domain.Position.new(1, 5), find_partial.endpoint)
+ same(2, find_partial.successful_steps)
+
+ local till_view = text_topology.new({ "abxb" }, "utf-8")
+ local till_plan = motion_plan.build(
+ target_plan.build(target("b"), matching_policy()),
+ "t"
+ )
+ local till_partial = engine:calculate(
+ till_view,
+ domain.Position.new(1, 1),
+ till_plan,
+ 3,
+ true
+ )
+ same(domain.SearchStatus.BOUNDARY_AFTER_PARTIAL, till_partial.status)
+ same(domain.Position.new(1, 3), till_partial.endpoint)
+ same(2, till_partial.successful_steps)
+end)
+
for _, item in ipairs(tests) do
local ok, failure = xpcall(item.body, debug.traceback)
if not ok then