From c6f2c9941742c84a43faee9e6426786bc1e8f13c Mon Sep 17 00:00:00 2001 From: Jackson Moore Date: Fri, 4 Sep 2026 12:32:44 +0200 Subject: Apply persistent match behavior --- tests/run.lua | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'tests') 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 -- cgit v1.2.3