diff options
| author | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 12:41:06 +0200 |
|---|---|---|
| committer | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 12:41:06 +0200 |
| commit | 70bc720156f8ff315fcf54f478becfdf098f3994 (patch) | |
| tree | 4964af822d39d9485e10f802b73199e971f8af76 | |
| parent | 69000b4e6acf9ecad0d3d9220bca6c1433993d6c (diff) | |
Detect cross-line feedback migration
| -rw-r--r-- | lua/clever_f/feedback_service.lua | 26 | ||||
| -rw-r--r-- | tests/run.lua | 25 |
2 files changed, 51 insertions, 0 deletions
diff --git a/lua/clever_f/feedback_service.lua b/lua/clever_f/feedback_service.lua index 6972d70..e553cd7 100644 --- a/lua/clever_f/feedback_service.lua +++ b/lua/clever_f/feedback_service.lua @@ -25,6 +25,10 @@ M.FinalizerAction = { PRESERVE = "preserve", FINALIZE = "finalize", } +M.MigrationReason = { + LINE_CHANGE = "line_change", + TILL_DIRECTION_CHANGE = "till_direction_change", +} local OVERLAY_PRIORITIES = { CleverFCursor = M.Priority.HIGH, @@ -603,6 +607,28 @@ function FeedbackService:persistent_requests() return result end +function M.command_migration_reason(request) + if type(request) ~= "table" then + fail("command feedback migration request must be a table", 2) + end + local origin = domain.Position.coerce(request.origin) + local destination = domain.Position.coerce(request.destination) + if request.outcome ~= nil and request.outcome.complete ~= true then + return nil + end + if origin.line ~= destination.line then + return M.MigrationReason.LINE_CHANGE + end + return nil +end + +function FeedbackService:migrate_command(request) + return { + migrated = false, + reason = M.command_migration_reason(request), + } +end + function FeedbackService:evaluate_feature_links() local record = service_records[self] local rules = record.policy:evaluate_highlight_links() diff --git a/tests/run.lua b/tests/run.lua index b0f9cee..e73dda7 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -6374,6 +6374,31 @@ test("Full feedback finalization preserves reusable sequence data", function() same(dictionary, state:get_migemo("utf-8")) end) +test("Command feedback migration compares origin and destination lines", function() + same( + nil, + feedback_service.command_migration_reason({ + origin = domain.Position.new(2, 1), + destination = domain.Position.new(2, 7), + }) + ) + same( + feedback_service.MigrationReason.LINE_CHANGE, + feedback_service.command_migration_reason({ + origin = domain.Position.new(2, 7), + destination = domain.Position.new(3, 1), + }) + ) + same( + nil, + feedback_service.command_migration_reason({ + origin = domain.Position.new(2, 7), + destination = domain.Position.new(3, 1), + outcome = { complete = false }, + }) + ) +end) + for _, item in ipairs(tests) do local ok, failure = xpcall(item.body, debug.traceback) if not ok then |
