summaryrefslogtreecommitdiff
path: root/tests/run.lua
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run.lua')
-rw-r--r--tests/run.lua55
1 files changed, 53 insertions, 2 deletions
diff --git a/tests/run.lua b/tests/run.lua
index 42ebe89..1df3d0e 100644
--- a/tests/run.lua
+++ b/tests/run.lua
@@ -4935,7 +4935,8 @@ test("Acquisition creates cursor markers only when enabled", function()
truthy(marker ~= nil)
same(domain.Position.new(1, 4), marker.position)
same("window-1", marker.window)
- same(marker.identity, state:temporary_overlay_identities()[1])
+ same(0, #state:temporary_overlay_identities())
+ same(nil, host:highlights()[marker.identity])
fresh_sequence_state()
local disabled = acquisition_service.new(MemoryHost.new({
@@ -5008,7 +5009,8 @@ test("Interactive acquisition creates enabled direct previews", function()
same("CleverFDirect", marker.group)
same(1, #marker.positions)
same(domain.Position.new(1, 4), marker.positions[1])
- same(marker.identity, state:temporary_overlay_identities()[1])
+ same(0, #state:temporary_overlay_identities())
+ same(nil, host:highlights()[marker.identity])
list_same({ "screen" }, host:redraws())
local create_index
local redraw_index
@@ -5512,6 +5514,55 @@ test("Completed interactive prompt input requests a full redraw", function()
same(0, #escape_host:redraws())
end)
+test("Acquisition releases direct cursor and presentation resources", function()
+ local state = fresh_sequence_state()
+ local prior = {
+ hidden = false,
+ guicursor = "n:block",
+ terminal_cursor_visible = true,
+ }
+ local host = MemoryHost.new({
+ buffer_lines = { "abc" },
+ cursor_presentation = prior,
+ configuration = {
+ mark_cursor = true,
+ mark_direct = true,
+ mark_char = false,
+ },
+ input_packets = { { kind = "text", text = "b" } },
+ })
+ local service = acquisition_service.new(host)
+ service:acquire("f", "n", domain.Position.new(1, 1), nil, nil)
+
+ local scope = service:last_temporary_scope()
+ falsy(scope.active)
+ truthy(scope.direct_marker ~= nil)
+ truthy(scope.cursor_marker ~= nil)
+ same(0, #state:temporary_overlay_identities())
+ same(nil, host:highlights()[scope.direct_marker.identity])
+ same(nil, host:highlights()[scope.cursor_marker.identity])
+ same(prior.hidden, host:cursor_presentation().hidden)
+ same(prior.guicursor, host:cursor_presentation().guicursor)
+ same(
+ prior.terminal_cursor_visible,
+ host:cursor_presentation().terminal_cursor_visible
+ )
+
+ local removals = {}
+ local restore_index
+ for index, operation in ipairs(host:operations()) do
+ if operation.operation == "remove_highlight" then
+ removals[#removals + 1] = { index = index, identity = operation.identity }
+ elseif operation.operation == "restore_cursor_presentation" then
+ restore_index = index
+ end
+ end
+ same(2, #removals)
+ same(scope.direct_marker.identity, removals[1].identity)
+ same(scope.cursor_marker.identity, removals[2].identity)
+ truthy(restore_index > removals[2].index)
+end)
+
for _, item in ipairs(tests) do
local ok, failure = xpcall(item.body, debug.traceback)
if not ok then