diff options
| author | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 11:44:56 +0200 |
|---|---|---|
| committer | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 11:44:56 +0200 |
| commit | f9c8b8dcc072bc82302217f3a2353e3d351160f8 (patch) | |
| tree | eee5c16fa353ebed24c9875c6a81055145c9d9c1 | |
| parent | 5a51b5692e29ac4ab2ceda5888126745b99823d7 (diff) | |
Mark TILL target occurrences
| -rw-r--r-- | lua/clever_f/direct_preview_planner.lua | 7 | ||||
| -rw-r--r-- | tests/run.lua | 17 |
2 files changed, 23 insertions, 1 deletions
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 |
