diff options
| -rw-r--r-- | lua/clever_f/feedback_service.lua | 10 | ||||
| -rw-r--r-- | tests/run.lua | 34 |
2 files changed, 43 insertions, 1 deletions
diff --git a/lua/clever_f/feedback_service.lua b/lua/clever_f/feedback_service.lua index b8a503d..bb78c17 100644 --- a/lua/clever_f/feedback_service.lua +++ b/lua/clever_f/feedback_service.lua @@ -21,6 +21,10 @@ M.FINALIZER_EVENTS = { "InsertEnter", "TextChanged", } +M.FinalizerAction = { + PRESERVE = "preserve", + FINALIZE = "finalize", +} local OVERLAY_PRIORITIES = { CleverFCursor = M.Priority.HIGH, @@ -480,7 +484,11 @@ end function FeedbackService:handle_finalizer_event(name) if name == "CursorMoved" then - return self:cursor_moved_decision() + local decision = self:cursor_moved_decision() + if decision.equal then + decision.action = M.FinalizerAction.PRESERVE + end + return decision end return false end diff --git a/tests/run.lua b/tests/run.lua index 902d846..baa8f29 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -6159,6 +6159,40 @@ test("CursorMoved compares the actual cursor with the last-input landing", funct falsy(different.equal) end) +test("Matching CursorMoved preserves the active sequence", function() + local state, transitions = fresh_sequence_state() + local landing = domain.Position.new(1, 3) + local host = MemoryHost.new({ + buffer_lines = { "aba" }, + cursor = landing, + }) + local feedback = feedback_service.new({ + host = host, + transitions = transitions, + }) + local shared_target = target_plan.build(target("a"), matching_policy()) + local movement = motion_plan.build(shared_target, "f") + transitions:BeginAcquisition("n", "f") + transitions:CommitAcquiredTarget("n", target("a")) + feedback:request_persistent({ + context = "n", + anchor = domain.Position.new(1, 1), + target_plan = shared_target, + motion_plan = movement, + window = "window-1", + }) + transitions:CommitCommandSuccess("n", landing, true) + local before = state:snapshot() + + host:deliver_event("CursorMoved", { cursor = landing }) + + same(before.previous_descriptor[domain.ModeContext.from_full_mode("n")], + state:get_previous_descriptor("n")) + same(landing, state:get_previous_landing("n")) + same(1, #state.target_overlays) + same(1, #state.finalizers) +end) + for _, item in ipairs(tests) do local ok, failure = xpcall(item.body, debug.traceback) if not ok then |
