summaryrefslogtreecommitdiff
path: root/tests/run.lua
diff options
context:
space:
mode:
authorJackson Moore <jacksonmoore@tuta.io>2026-09-04 10:27:53 +0200
committerJackson Moore <jacksonmoore@tuta.io>2026-09-04 10:27:53 +0200
commitfafe4dfe8ae5ef86ead6667f6d821c32cb5e13ed (patch)
tree351a789a76e72088a1799f9861b810db429c1b29 /tests/run.lua
parent1d7cf6fe16c4b1e9a2cfc71b9feb098118cf7ca8 (diff)
Stop counts at search boundaries
Diffstat (limited to 'tests/run.lua')
-rw-r--r--tests/run.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/run.lua b/tests/run.lua
index 209cf28..c6905b5 100644
--- a/tests/run.lua
+++ b/tests/run.lua
@@ -2744,6 +2744,33 @@ test("Sequential counts reuse each accepted destination as origin", function()
)
end)
+test("Count calculation stops when its fixed boundary is reached", function()
+ local visits = 0
+ local view = text_topology.new({ "axaxa" }, "utf-8")
+ local target_match = domain.TargetPlan.new({
+ target = target("a"),
+ kind = domain.TargetPlanKind.LITERAL,
+ case_mode = domain.CaseMode.SENSITIVE,
+ matcher = function(character)
+ visits = visits + 1
+ return character == "a"
+ end,
+ })
+ local plan = motion_plan.build(target_match, "f", "buffer")
+ local engine = destination_engine.new()
+ local origin = domain.Position.new(1, 1)
+
+ local complete = engine:calculate(view, origin, plan, 2, true)
+ same(domain.SearchStatus.COMPLETE, complete.status)
+ same(domain.Position.new(1, 5), complete.endpoint)
+ same(4, visits)
+
+ visits = 0
+ local incomplete = engine:calculate(view, origin, plan, 3, true)
+ falsy(incomplete.complete)
+ same(4, visits)
+end)
+
for _, item in ipairs(tests) do
local ok, failure = xpcall(item.body, debug.traceback)
if not ok then