From f838dddfc1ba8ea6f1ec3b6cf5fd2c2fcedf637d Mon Sep 17 00:00:00 2001 From: Jackson Moore Date: Fri, 4 Sep 2026 12:16:53 +0200 Subject: Preserve acquisition pre-input state --- tests/run.lua | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/run.lua b/tests/run.lua index 1c7d39e..f954b7c 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -5693,6 +5693,43 @@ test("Macro acquisition skips direct planning and all redraws", function() same(0, #host:redraws()) end) +test("Acquisition preserves descriptor writes after input failure", function() + local state, transitions = fresh_sequence_state() + local old_target = domain.TargetValue.character("z", 122) + transitions:BeginAcquisition("n", "T") + transitions:CommitAcquiredTarget("n", old_target) + transitions:CommitCommandSuccess( + "n", + domain.Position.new(1, 2), + domain.Direction.BACKWARD + ) + local host = MemoryHost.new({ + buffer_lines = { "abc" }, + cursor = { line = 1, byte_column = 2 }, + configuration = { + mark_cursor = false, + mark_char = false, + }, + input_packets = { { kind = "error", message = "read failed" } }, + }) + local service = acquisition_service.new({ + host = host, + transitions = transitions, + }) + + local result = service:acquire( + "f", + "n", + domain.Position.new(1, 2), + nil, + nil + ) + same(domain.ActionKind.ERROR, result.outcome.kind) + same(domain.Descriptor.FIND_FORWARD, state:get_previous_descriptor("n")) + truthy(state:get_first_move("n")) + same(old_target, state:get_previous_target("n")) +end) + for _, item in ipairs(tests) do local ok, failure = xpcall(item.body, debug.traceback) if not ok then -- cgit v1.2.3