summaryrefslogtreecommitdiff
path: root/lua/clever_f
diff options
context:
space:
mode:
authorJackson Moore <jacksonmoore@tuta.io>2026-09-04 10:19:02 +0200
committerJackson Moore <jacksonmoore@tuta.io>2026-09-04 10:19:02 +0200
commit272c9cef5d40c9100968e1250036d74fa9868f71 (patch)
treee44cbb4c4657256aa1ed6674d679887a3c90184d /lua/clever_f
parent55a3a9dbb4d0ec6ecf20576bfa276298563257b8 (diff)
Enumerate matching target starts
Diffstat (limited to 'lua/clever_f')
-rw-r--r--lua/clever_f/destination_engine.lua24
1 files changed, 23 insertions, 1 deletions
diff --git a/lua/clever_f/destination_engine.lua b/lua/clever_f/destination_engine.lua
index 9b528d0..c17dc83 100644
--- a/lua/clever_f/destination_engine.lua
+++ b/lua/clever_f/destination_engine.lua
@@ -60,9 +60,31 @@ local function calculation_inputs(view, origin, plan, count, first_move)
}
end
+local function next_matching_start(request, origin)
+ local candidates = request.view:iter_strict(
+ origin,
+ request.plan.descriptor.direction,
+ request.bounds
+ )
+
+ while true do
+ local position, character = candidates()
+ if position == nil then
+ return nil
+ end
+ if request.plan.target_plan:matches(character, position, request.view) then
+ return position
+ end
+ end
+end
+
function DestinationEngine:calculate(view, origin, plan, count, first_move)
local request = calculation_inputs(view, origin, plan, count, first_move)
- return domain.SearchOutcome.boundary_before_any(request.origin)
+ local target_position = next_matching_start(request, request.origin)
+ if target_position == nil then
+ return domain.SearchOutcome.boundary_before_any(request.origin)
+ end
+ return domain.SearchOutcome.complete(target_position, 1)
end
function M.new()