summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/clever_f/destination_engine.lua24
1 files changed, 16 insertions, 8 deletions
diff --git a/lua/clever_f/destination_engine.lua b/lua/clever_f/destination_engine.lua
index 53b26fe..8a07328 100644
--- a/lua/clever_f/destination_engine.lua
+++ b/lua/clever_f/destination_engine.lua
@@ -149,15 +149,23 @@ end
function DestinationEngine:calculate(view, origin, plan, count, first_move)
local request = calculation_inputs(view, origin, plan, count, first_move)
- local destination = next_destination(
- request,
- request.origin,
- till_equality_allowed(request, 0)
- )
- if destination == nil then
- return domain.SearchOutcome.boundary_before_any(request.origin)
+ local current_origin = request.origin
+ local successful_steps = 0
+
+ while successful_steps < request.count.value do
+ local destination = next_destination(
+ request,
+ current_origin,
+ till_equality_allowed(request, successful_steps)
+ )
+ if destination == nil then
+ return domain.SearchOutcome.boundary_before_any(request.origin)
+ end
+ current_origin = destination
+ successful_steps = successful_steps + 1
end
- return domain.SearchOutcome.complete(destination, 1)
+
+ return domain.SearchOutcome.complete(current_origin, successful_steps)
end
function M.new()