diff options
| author | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 12:03:36 +0200 |
|---|---|---|
| committer | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 12:03:36 +0200 |
| commit | 44b0624d22ea62983cae7737a0b1d1bd0280c5e5 (patch) | |
| tree | 3df7b1cb63067f8ce4fb5249226dbe478ab03096 /tests | |
| parent | dbbbe30b637fccfacb15cd7317d4af87b658cfb5 (diff) | |
Return Escape acquisition outcomes
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/run.lua | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/tests/run.lua b/tests/run.lua index c279844..9ce65d2 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -4901,7 +4901,7 @@ test("Acquisition starts one temporary resource scope", function() local service = acquisition_service.new(MemoryHost.new({ input_packets = { { kind = "text", text = "a" } }, })) - local request = service:acquire( + local result = service:acquire( "f", "n", domain.Position.new(1, 1), @@ -4910,9 +4910,10 @@ test("Acquisition starts one temporary resource scope", function() ) local scope = service:last_temporary_scope() - truthy(acquisition_service.AcquisitionRequest.is(request)) + truthy(acquisition_service.AcquisitionResult.is(result)) + truthy(acquisition_service.AcquisitionRequest.is(result.request)) truthy(acquisition_service.TemporaryResourceScope.is(scope)) - same(request, scope.request) + same(result.request, scope.request) truthy(scope.active) same(1, service:started_scope_count()) end) @@ -5129,6 +5130,35 @@ test("Acquisition reads one raw packet after sequence start", function() same(1, reads) end) +test("Escape acquisition preserves the cursor and returns Escape", function() + fresh_sequence_state() + local origin = domain.Position.new(2, 3) + local host = MemoryHost.new({ + buffer_lines = { "abc", "abcd" }, + cursor = origin, + configuration = { + mark_cursor = false, + hide_cursor_on_cmdline = false, + }, + input_packets = { + { kind = "special_key", name = "Escape", bytes = { 27 } }, + }, + }) + local service = acquisition_service.new(host) + + local result = service:acquire("f", "n", origin, nil, nil) + truthy(acquisition_service.AcquisitionResult.is(result)) + truthy(result:has_outcome()) + same(domain.ActionKind.ESCAPE, result.outcome.kind) + same(origin, result.outcome.position) + same(origin, host:read_cursor()) + same(nil, result.target) + falsy(service:last_temporary_scope().active) + truthy(acquisition_service.is_escape( + domain.InputPacket.raw_bytes({ 27 }) + )) +end) + test("Acquisition discards the terminal artifact packet", function() fresh_sequence_state() local artifact = domain.InputPacket.raw_bytes({ 0x80, 0xfd, 0x60 }) |
