summaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/clever_f/destination_engine.lua31
1 files changed, 24 insertions, 7 deletions
diff --git a/lua/clever_f/destination_engine.lua b/lua/clever_f/destination_engine.lua
index 0ae2314..e3a7fc1 100644
--- a/lua/clever_f/destination_engine.lua
+++ b/lua/clever_f/destination_engine.lua
@@ -100,14 +100,22 @@ local function strict_destination(descriptor, destination, origin)
return comparison < 0
end
-local function acceptable_destination(request, destination, origin)
- if request.plan.descriptor.family == domain.Family.FIND then
- return strict_destination(request.plan.descriptor, destination, origin)
+local function acceptable_destination(
+ request,
+ destination,
+ origin,
+ allow_till_equality
+)
+ local descriptor = request.plan.descriptor
+ if strict_destination(descriptor, destination, origin) then
+ return true
end
- return true
+ return descriptor.family == domain.Family.TILL
+ and allow_till_equality
+ and domain.Position.equal(destination, origin)
end
-local function next_destination(request, origin)
+local function next_destination(request, origin, allow_till_equality)
local candidates = candidate_starts(request, origin)
while true do
@@ -122,7 +130,12 @@ local function next_destination(request, origin)
) then
local destination = target_destination(request, target_position)
if destination ~= nil
- and acceptable_destination(request, destination, origin)
+ and acceptable_destination(
+ request,
+ destination,
+ origin,
+ allow_till_equality
+ )
then
return destination
end
@@ -132,7 +145,11 @@ 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)
+ local destination = next_destination(
+ request,
+ request.origin,
+ request.first_move
+ )
if destination == nil then
return domain.SearchOutcome.boundary_before_any(request.origin)
end