From f9c8b8dcc072bc82302217f3a2353e3d351160f8 Mon Sep 17 00:00:00 2001 From: Jackson Moore Date: Fri, 4 Sep 2026 11:44:56 +0200 Subject: Mark TILL target occurrences --- lua/clever_f/direct_preview_planner.lua | 7 ++++++- tests/run.lua | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lua/clever_f/direct_preview_planner.lua b/lua/clever_f/direct_preview_planner.lua index bd15870..404191e 100644 --- a/lua/clever_f/direct_preview_planner.lua +++ b/lua/clever_f/direct_preview_planner.lua @@ -72,6 +72,11 @@ function DirectPreviewPlanner:scan_current_line(view, origin, direction) return records end +function M.marker_position(descriptor, target_position) + domain.Descriptor.from_string(descriptor) + return domain.Position.coerce(target_position) +end + function M.normalize_count(count) return domain.Count.to_number(count) end @@ -165,7 +170,7 @@ function DirectPreviewPlanner:plan(view, origin, descriptor, count, settings) ) == selected_occurrence end if selected then - positions[#positions + 1] = record.position + positions[#positions + 1] = M.marker_position(descriptor, record.position) end end return positions diff --git a/tests/run.lua b/tests/run.lua index 718488b..458b521 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -4735,6 +4735,23 @@ test("Smart-case previews mark the exact and lowercase union", function() same(domain.Position.new(1, 3), one_marker[1]) end) +test("TILL direct previews retain target occurrence positions", function() + local planner = direct_preview_planner.new({ lowercase = string.lower }) + local view = text_topology.new({ "xaxa" }, "utf-8") + local origin = domain.Position.new(1, 1) + + local find_positions = planner:plan(view, origin, "f", 2) + local till_positions = planner:plan(view, origin, "t", 2) + same(1, #find_positions) + same(1, #till_positions) + same(domain.Position.new(1, 4), find_positions[1]) + same(find_positions[1], till_positions[1]) + same( + domain.Position.new(1, 4), + direct_preview_planner.marker_position("t", domain.Position.new(1, 4)) + ) +end) + for _, item in ipairs(tests) do local ok, failure = xpcall(item.body, debug.traceback) if not ok then -- cgit v1.2.3