From e695cb4b3a7637edf44058c17f4822bb39e74f6e Mon Sep 17 00:00:00 2001 From: Jackson Moore Date: Fri, 4 Sep 2026 12:53:28 +0200 Subject: Preserve eager cleanup history --- tests/run.lua | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'tests/run.lua') diff --git a/tests/run.lua b/tests/run.lua index 2fa6540..b1555c2 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -7016,6 +7016,58 @@ test("MemoryHost limits scoped events to their buffer", function() same(2, deliveries) end) +test("Eager cleanup preserves history and finalizer registrations", function() + local state, transitions = fresh_sequence_state() + local target_value = target("a") + local landing = domain.Position.new(1, 3) + local dictionary = { name = "utf-8" } + local host = MemoryHost.new({ + buffer_lines = { "aba" }, + configuration = { + clean_labels_eagerly = true, + mark_char = true, + highlight_timeout_ms = 25, + }, + }) + local feedback = feedback_service.new({ + host = host, + transitions = transitions, + }) + local activation = feedback:activate() + local shared_target = target_plan.build(target_value, matching_policy()) + local movement = motion_plan.build(shared_target, "f") + transitions:BeginAcquisition("n", "f") + transitions:CommitAcquiredTarget("n", target_value, 87) + transitions:CommitCommandSuccess("n", landing, true) + transitions:CacheMigemo("utf-8", dictionary) + local persistent = feedback:request_persistent({ + context = "n", + anchor = domain.Position.new(1, 1), + target_plan = shared_target, + motion_plan = movement, + window = "window-1", + }) + feedback:start_highlight_timer("window-1") + + host:deliver_event("WinLeave", { window = "window-1" }) + + same(domain.Descriptor.FIND_FORWARD, state:get_previous_descriptor("n")) + same(target_value, state:get_previous_target("n")) + same(landing, state:get_previous_landing("n")) + falsy(state:get_first_move("n")) + truthy(state.moved_forward) + truthy(state.moved_forward_initialized) + same(domain.ModeContext.from_full_mode("n"), state.last_input_context) + same(dictionary, state:get_migemo("utf-8")) + same(87, state.repeat_timestamp_ms) + same(1, #state.finalizers) + same(persistent.finalizers.identity, state.finalizers[1].identity) + truthy(host:event_registrations()[persistent.finalizers.identity].active) + truthy(host:event_registrations()[activation.eager_registration].active) + same(0, #state.target_overlays) + same(nil, state.highlight_timer) +end) + for _, item in ipairs(tests) do local ok, failure = xpcall(item.body, debug.traceback) if not ok then @@ -7025,4 +7077,4 @@ for _, item in ipairs(tests) do passed = passed + 1 end -io.stdout:write(string.format("Phase 12: %d tests passed\n", passed)) +io.stdout:write(string.format("Phase 13: %d tests passed\n", passed)) -- cgit v1.2.3