diff options
| author | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 12:43:53 +0200 |
|---|---|---|
| committer | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 12:43:53 +0200 |
| commit | 4aa8704dc0de5a691ddd5a71f0e3a81659463798 (patch) | |
| tree | 89bdbc51c4e2034015c3b389698db7f1b30613be | |
| parent | f43bc1874ecb8a2b8230e3af82a5a28170bfd810 (diff) | |
Gate persistent highlight timeout
| -rw-r--r-- | lua/clever_f/feedback_service.lua | 15 | ||||
| -rw-r--r-- | tests/run.lua | 28 |
2 files changed, 43 insertions, 0 deletions
diff --git a/lua/clever_f/feedback_service.lua b/lua/clever_f/feedback_service.lua index 9c2cdc3..98f51aa 100644 --- a/lua/clever_f/feedback_service.lua +++ b/lua/clever_f/feedback_service.lua @@ -120,6 +120,7 @@ local function require_host(host) or type(host.register_events) ~= "function" or type(host.remove_event_registration) ~= "function" or type(host.stop_timer) ~= "function" + or type(host.supports_timers) ~= "function" or type(host.supports_cursor_presentation) ~= "function" or type(host.suppress_cursor_presentation) ~= "function" or type(host.restore_cursor_presentation) ~= "function" @@ -150,6 +151,8 @@ local function require_policy(service, host) if type(service) ~= "table" or type(service.evaluate_highlight_links) ~= "function" or type(service.sample_acquisition) ~= "function" + or type(service.sample_markers) ~= "function" + or type(service.sample_timeouts) ~= "function" then fail("FeedbackService policy must evaluate highlight links", 3) end @@ -687,6 +690,18 @@ function FeedbackService:migrate_command(request) } end +function FeedbackService:highlight_timer_delay() + local record = service_records[self] + if not record.policy:sample_markers().mark_char then + return nil + end + local delay = record.policy:sample_timeouts().highlight_timeout_ms + if delay == 0 or record.host:supports_timers() ~= true then + return nil + end + return delay +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 c626444..aa01e7f 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -6561,6 +6561,34 @@ test("Visual movement retains its persistent feedback anchor", function() truthy(host:highlights()[persistent.identity] ~= nil) end) +test("Highlight timeout requires marks delay and timer support", function() + for _, mark_char in ipairs({ false, true }) do + for _, delay in ipairs({ 0, 25 }) do + for _, supported in ipairs({ false, true }) do + fresh_sequence_state() + local host = MemoryHost.new({ + configuration = { + mark_char = mark_char, + highlight_timeout_ms = delay, + }, + timer_support = supported, + }) + local actual = feedback_service.new(host):highlight_timer_delay() + local expected = mark_char and delay > 0 and supported and delay or nil + same( + expected, + actual, + table.concat({ + tostring(mark_char), + tostring(delay), + tostring(supported), + }, ":") + ) + end + end + end +end) + for _, item in ipairs(tests) do local ok, failure = xpcall(item.body, debug.traceback) if not ok then |
