summaryrefslogtreecommitdiff
path: root/tests/run.lua
diff options
context:
space:
mode:
authorJackson Moore <jacksonmoore@tuta.io>2026-09-04 12:32:44 +0200
committerJackson Moore <jacksonmoore@tuta.io>2026-09-04 12:32:44 +0200
commitc6f2c9941742c84a43faee9e6426786bc1e8f13c (patch)
treecd14010eb2d37aed874e2395f7b707acfbe4cbd4 /tests/run.lua
parenta32ac60fad13db062f23478e8da74d5dbba0edc8 (diff)
Apply persistent match behavior
Diffstat (limited to 'tests/run.lua')
-rw-r--r--tests/run.lua61
1 files changed, 61 insertions, 0 deletions
diff --git a/tests/run.lua b/tests/run.lua
index 57f4988..b044379 100644
--- a/tests/run.lua
+++ b/tests/run.lua
@@ -5872,6 +5872,67 @@ test("Persistent feedback uses its selected descriptor and endpoint policy", fun
same(domain.EndpointPolicy.VISUAL_EXCLUSIVE, selected.endpoint_policy)
end)
+test("Persistent positions apply target predicates and endpoint transforms", function()
+ local view = text_topology.new({ "aA!\\\227\129\130" }, "utf-8")
+ local insensitive = target_plan.build(target("a"), {
+ ignore_case = true,
+ smart_case = false,
+ use_migemo = false,
+ chars_match_any_signs = "",
+ })
+ local symbols = target_plan.build(target("!"), {
+ ignore_case = false,
+ smart_case = false,
+ use_migemo = false,
+ chars_match_any_signs = "!",
+ })
+ local backslash = target_plan.build(target("\\"), matching_policy())
+ local migemo = domain.TargetPlan.new({
+ target = target("a"),
+ kind = domain.TargetPlanKind.MIGEMO,
+ case_mode = domain.CaseMode.SENSITIVE,
+ matcher = function(character)
+ return character == "\227\129\130"
+ end,
+ })
+ local function columns(plan)
+ local result = {}
+ for index, position in ipairs(feedback_service.persistent_match_positions(
+ view,
+ 1,
+ plan,
+ "f",
+ domain.EndpointPolicy.REGULAR
+ )) do
+ result[index] = position.byte_column
+ end
+ return result
+ end
+
+ list_same({ 1, 2 }, columns(insensitive))
+ list_same({ 3, 4 }, columns(symbols))
+ list_same({ 4 }, columns(backslash))
+ list_same({ 5 }, columns(migemo))
+ same(
+ domain.Position.new(1, 1),
+ feedback_service.persistent_destination(
+ view,
+ domain.Position.new(1, 2),
+ "t",
+ domain.EndpointPolicy.REGULAR
+ )
+ )
+ same(
+ domain.Position.new(1, 2),
+ feedback_service.persistent_destination(
+ view,
+ domain.Position.new(1, 2),
+ "t",
+ domain.EndpointPolicy.VISUAL_EXCLUSIVE
+ )
+ )
+end)
+
for _, item in ipairs(tests) do
local ok, failure = xpcall(item.body, debug.traceback)
if not ok then