From d3288bd81eb106ec0100030e6cce083231355329 Mon Sep 17 00:00:00 2001 From: Jackson Moore Date: Fri, 4 Sep 2026 12:16:32 +0200 Subject: Suppress macro acquisition redraws --- lua/clever_f/acquisition_service.lua | 20 ++++++++++++++----- tests/run.lua | 37 ++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/lua/clever_f/acquisition_service.lua b/lua/clever_f/acquisition_service.lua index 5cbe6ab..103054a 100644 --- a/lua/clever_f/acquisition_service.lua +++ b/lua/clever_f/acquisition_service.lua @@ -252,6 +252,18 @@ function TemporaryResourceScope:set_input_packet(packet) return set_scope_resource(self, "input_packet", packet) end +function TemporaryResourceScope:request_redraw(kind) + local record = scope_records[self] + if record == nil then + fail("temporary resource scope is invalid", 2) + end + if not record.interactive then + return false + end + record.host:redraw(kind) + return true +end + function TemporaryResourceScope:mark_prompt_shown() return set_scope_resource(self, "prompt_shown", true) end @@ -340,7 +352,7 @@ function TemporaryResourceScope:release() and record.acquisition_completed then release_operation(function() - record.host:redraw("full") + self:request_redraw("full") end) end if record.direct_marker ~= nil then @@ -732,9 +744,7 @@ local function acquire_in_scope(record, request, scope) request.position, current_window(record) )) - if interactive then - record.host:redraw("screen") - end + scope:request_redraw("screen") end if acquisition.mark_direct and interactive then local view = scope:set_text_view(text_topology.from_host(record.host)) @@ -752,7 +762,7 @@ local function acquire_in_scope(record, request, scope) positions, window )) - record.host:redraw("screen") + scope:request_redraw("screen") end if acquisition.show_prompt and interactive then record.host:show_prompt(M.PROMPT) diff --git a/tests/run.lua b/tests/run.lua index b4519fe..1c7d39e 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -5656,6 +5656,43 @@ test("Each macro acquisition consumes and commits input", function() same(2, reads) end) +test("Macro acquisition skips direct planning and all redraws", function() + fresh_sequence_state() + local direct_calls = 0 + local direct_planner = { + plan = function() + direct_calls = direct_calls + 1 + error("macro direct planner must stay idle") + end, + } + local host = MemoryHost.new({ + buffer_lines = { "abc" }, + configuration = { + mark_cursor = true, + mark_direct = true, + mark_char = false, + show_prompt = true, + }, + input_packets = { { kind = "text", text = "b" } }, + }) + local service = acquisition_service.new({ + host = host, + direct_planner = direct_planner, + }) + + local result = service:acquire( + "f", + "n", + domain.Position.new(1, 1), + nil, + "q" + ) + same("b", result.target.value) + same(0, direct_calls) + same(nil, service:last_temporary_scope().direct_marker) + same(0, #host:redraws()) +end) + for _, item in ipairs(tests) do local ok, failure = xpcall(item.body, debug.traceback) if not ok then -- cgit v1.2.3