summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/run.lua36
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 })