summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJackson Moore <jacksonmoore@tuta.io>2026-09-04 12:16:53 +0200
committerJackson Moore <jacksonmoore@tuta.io>2026-09-04 12:16:53 +0200
commitf838dddfc1ba8ea6f1ec3b6cf5fd2c2fcedf637d (patch)
treededd52c456d2118b0a2044a7122e2dd515a7199e /tests
parentd3288bd81eb106ec0100030e6cce083231355329 (diff)
Preserve acquisition pre-input state
Diffstat (limited to 'tests')
-rw-r--r--tests/run.lua37
1 files changed, 37 insertions, 0 deletions
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