diff options
| author | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 10:22:02 +0200 |
|---|---|---|
| committer | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 10:22:02 +0200 |
| commit | 80496b38064f1abde2b5870955bd73b7d3a3d794 (patch) | |
| tree | d2f32e6d99501b1731fedf326c8ca53c7d1d3b1f | |
| parent | 1a9f90afcc6e5e00a94dd188a5361a894d06e257 (diff) | |
Adjust exclusive FIND destinations
| -rw-r--r-- | lua/clever_f/destination_engine.lua | 10 | ||||
| -rw-r--r-- | tests/run.lua | 27 |
2 files changed, 37 insertions, 0 deletions
diff --git a/lua/clever_f/destination_engine.lua b/lua/clever_f/destination_engine.lua index ed3b7b2..5e60736 100644 --- a/lua/clever_f/destination_engine.lua +++ b/lua/clever_f/destination_engine.lua @@ -94,6 +94,13 @@ local function regular_destination(request, target_position) end local function target_destination(request, target_position) + local descriptor = request.plan.descriptor + if request.plan.endpoint_policy == domain.EndpointPolicy.VISUAL_EXCLUSIVE + and descriptor.direction == domain.Direction.FORWARD + and descriptor.family == domain.Family.FIND + then + return request.view:successor(target_position) + end return regular_destination(request, target_position) end @@ -104,6 +111,9 @@ function DestinationEngine:calculate(view, origin, plan, count, first_move) return domain.SearchOutcome.boundary_before_any(request.origin) end local destination = target_destination(request, target_position) + if destination == nil then + return domain.SearchOutcome.boundary_before_any(request.origin) + end return domain.SearchOutcome.complete(destination, 1) end diff --git a/tests/run.lua b/tests/run.lua index e045a7e..4872cfd 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -2417,6 +2417,33 @@ test("Backward TILL destinations use target successors", function() truthy(cross_line_view:is_valid_cursor_position(cross_line.endpoint)) end) +test("Forward Visual-exclusive FIND uses target successors", function() + local view = text_topology.new({ "abx", "cd" }, "utf-8") + local engine = destination_engine.new() + local target_match = target_plan.build(target("x"), matching_policy()) + local regular = motion_plan.build( + target_match, + "f", + "buffer", + domain.EndpointPolicy.REGULAR + ) + local exclusive = motion_plan.build( + target_match, + "f", + "buffer", + domain.EndpointPolicy.VISUAL_EXCLUSIVE + ) + local origin = domain.Position.new(1, 1) + + same( + domain.Position.new(1, 3), + engine:calculate(view, origin, regular, 1, true).endpoint + ) + local adjusted = engine:calculate(view, origin, exclusive, 1, true) + same(domain.Position.new(2, 1), adjusted.endpoint) + truthy(view:is_valid_cursor_position(adjusted.endpoint)) +end) + for _, item in ipairs(tests) do local ok, failure = xpcall(item.body, debug.traceback) if not ok then |
