summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJackson Moore <jacksonmoore@tuta.io>2026-09-04 10:23:02 +0200
committerJackson Moore <jacksonmoore@tuta.io>2026-09-04 10:23:02 +0200
commit6449ffa5406ab4573f2148f23da06ed8d10d6ac4 (patch)
tree292c0a44fe94b8757d57d8c86bbee80e856aa7d3
parent80496b38064f1abde2b5870955bd73b7d3a3d794 (diff)
Adjust exclusive TILL destinations
-rw-r--r--lua/clever_f/destination_engine.lua6
-rw-r--r--tests/run.lua51
2 files changed, 55 insertions, 2 deletions
diff --git a/lua/clever_f/destination_engine.lua b/lua/clever_f/destination_engine.lua
index 5e60736..836d190 100644
--- a/lua/clever_f/destination_engine.lua
+++ b/lua/clever_f/destination_engine.lua
@@ -97,9 +97,11 @@ 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)
+ if descriptor.family == domain.Family.FIND then
+ return request.view:successor(target_position)
+ end
+ return target_position
end
return regular_destination(request, target_position)
end
diff --git a/tests/run.lua b/tests/run.lua
index 4872cfd..f9fbeb8 100644
--- a/tests/run.lua
+++ b/tests/run.lua
@@ -2444,6 +2444,57 @@ test("Forward Visual-exclusive FIND uses target successors", function()
truthy(view:is_valid_cursor_position(adjusted.endpoint))
end)
+test("Forward Visual-exclusive TILL uses target positions", function()
+ local view = text_topology.new({ "abx", "x" }, "utf-8")
+ local engine = destination_engine.new()
+ local target_match = target_plan.build(target("x"), matching_policy())
+ local regular = motion_plan.build(
+ target_match,
+ "t",
+ "buffer",
+ domain.EndpointPolicy.REGULAR
+ )
+ local exclusive = motion_plan.build(
+ target_match,
+ "t",
+ "buffer",
+ domain.EndpointPolicy.VISUAL_EXCLUSIVE
+ )
+ local origin = domain.Position.new(1, 1)
+
+ same(
+ domain.Position.new(1, 2),
+ engine:calculate(view, origin, regular, 1, true).endpoint
+ )
+ same(
+ domain.Position.new(1, 3),
+ engine:calculate(view, origin, exclusive, 1, true).endpoint
+ )
+
+ local cross_line_view = text_topology.new({ "abc", "x" }, "utf-8")
+ local cross_line_origin = domain.Position.new(1, 1)
+ same(
+ domain.Position.new(1, 3),
+ engine:calculate(
+ cross_line_view,
+ cross_line_origin,
+ regular,
+ 1,
+ false
+ ).endpoint
+ )
+ same(
+ domain.Position.new(2, 1),
+ engine:calculate(
+ cross_line_view,
+ cross_line_origin,
+ exclusive,
+ 1,
+ false
+ ).endpoint
+ )
+end)
+
for _, item in ipairs(tests) do
local ok, failure = xpcall(item.body, debug.traceback)
if not ok then