From 5199ca2e6527ce83b80898c57a09e984beb1fb67 Mon Sep 17 00:00:00 2001 From: Jackson Moore Date: Fri, 4 Sep 2026 14:21:14 +0200 Subject: Configure count-preserving mappings --- lua/clever_f/composition_root.lua | 7 ++++++- tests/run.lua | 27 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/lua/clever_f/composition_root.lua b/lua/clever_f/composition_root.lua index 0ea9675..f9c7a4c 100644 --- a/lua/clever_f/composition_root.lua +++ b/lua/clever_f/composition_root.lua @@ -20,6 +20,11 @@ M.ACTION_NAMES = { "RepeatOppositeDirection", } M.DEFAULT_MAPPING_MODES = { "n", "x", "o" } +M.DEFAULT_MAPPING_OPTIONS = { + silent = true, + remap = false, + preserve_count = true, +} M.DEFAULT_MAPPINGS = { { lhs = "f", action = "StartFindForward" }, { lhs = "F", action = "StartFindBackward" }, @@ -141,7 +146,7 @@ local function register_default_mappings(record, setup) M.DEFAULT_MAPPING_MODES, mapping.lhs, mapping.action, - {} + M.DEFAULT_MAPPING_OPTIONS ) end return registrations diff --git a/tests/run.lua b/tests/run.lua index d30aea4..87b6e73 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -7219,6 +7219,9 @@ test("Core activation installs four default mappings in required modes", functio same(expected.lhs, actual.lhs) same(expected.action, actual.action) list_same(composition_root.DEFAULT_MAPPING_MODES, actual.modes) + truthy(actual.options.silent) + falsy(actual.options.remap) + truthy(actual.options.preserve_count) end fresh_sequence_state() @@ -7230,6 +7233,30 @@ test("Core activation installs four default mappings in required modes", functio same(0, map_size(suppressed_host:mappings())) end) +test("Default mappings are silent non-recursive and count-preserving", function() + fresh_sequence_state() + local host = MemoryHost.new({ + buffer_lines = { "ababa" }, + cursor = { line = 1, byte_column = 1 }, + count = 2, + input_packets = { { kind = "text", text = "a" } }, + configuration = { + mark_cursor = false, + mark_char = false, + }, + emit_movement_events = false, + }) + local activation = composition_root.new({ host = host }):activate() + local mapping = host:mappings()[activation.mappings.f] + + truthy(mapping.options.silent) + falsy(mapping.options.remap) + truthy(mapping.options.preserve_count) + local outcome = host:invoke_action(mapping.action) + same(2, outcome.successful_steps) + same(domain.Position.new(1, 5), outcome.position) +end) + test("Primary coordination accepts only the four motion descriptors", function() local coordinator = sequence_coordinator.new({ host = MemoryHost.new() }) for _, value in ipairs({ "f", "F", "t", "T" }) do -- cgit v1.2.3