diff options
| author | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 12:48:48 +0200 |
|---|---|---|
| committer | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 12:48:48 +0200 |
| commit | 19904ba49a03a450e8a573358eb3417a3aafdb1f (patch) | |
| tree | 6a9913234c77586483ac68fc501be8784ae357d0 /lua | |
| parent | 23e121d2f74ad2dd1ab0902f120aa90bee2c7edb (diff) | |
Install sampled eager hooks
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/clever_f/feedback_service.lua | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lua/clever_f/feedback_service.lua b/lua/clever_f/feedback_service.lua index d4fd7a7..72ee1dc 100644 --- a/lua/clever_f/feedback_service.lua +++ b/lua/clever_f/feedback_service.lua @@ -21,6 +21,11 @@ M.FINALIZER_EVENTS = { "InsertEnter", "TextChanged", } +M.EAGER_EVENTS = { + "WinEnter", + "WinLeave", + "CmdwinLeave", +} M.FinalizerAction = { PRESERVE = "preserve", FINALIZE = "finalize", @@ -156,6 +161,7 @@ local function require_policy(service, host) or type(service.sample_acquisition) ~= "function" or type(service.sample_markers) ~= "function" or type(service.sample_timeouts) ~= "function" + or type(service.capture_activation) ~= "function" then fail("FeedbackService policy must evaluate highlight links", 3) end @@ -183,6 +189,8 @@ function FeedbackService.new(options) ), persistent_requests = {}, owned_finalizer = nil, + activation = nil, + eager_registration = nil, } return service end @@ -811,6 +819,35 @@ function FeedbackService:refresh_primary(resolved_target, window) return self:start_highlight_timer(window) end +function FeedbackService:handle_eager_event() + return false +end + +function FeedbackService:activate() + local record = service_records[self] + if record.activation ~= nil then + return copy(record.activation) + end + local sampled = record.policy:capture_activation() + local activation = { + clean_labels_eagerly = sampled.clean_labels_eagerly, + eager_registration = nil, + } + if sampled.clean_labels_eagerly then + local identity = record.host:register_events( + M.EAGER_EVENTS, + function(name, payload) + self:handle_eager_event(name, payload) + end, + { owner = "clever_f", lifecycle = "eager" } + ) + record.eager_registration = identity + activation.eager_registration = identity + end + record.activation = activation + return copy(activation) +end + function FeedbackService:evaluate_feature_links() local record = service_records[self] local rules = record.policy:evaluate_highlight_links() |
