diff options
| author | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 14:17:42 +0200 |
|---|---|---|
| committer | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 14:17:42 +0200 |
| commit | ac2d32dd0d7f73018613bea80ebd2823508c0105 (patch) | |
| tree | 14d87954a7635594d7aa63db1565027d164c046a | |
| parent | 2fb7acaea6252f2eb63427fd1e69645d319144c2 (diff) | |
Register colorscheme highlight refresh
| -rw-r--r-- | lua/clever_f/composition_root.lua | 16 | ||||
| -rw-r--r-- | tests/run.lua | 22 |
2 files changed, 37 insertions, 1 deletions
diff --git a/lua/clever_f/composition_root.lua b/lua/clever_f/composition_root.lua index 8d75359..527fec6 100644 --- a/lua/clever_f/composition_root.lua +++ b/lua/clever_f/composition_root.lua @@ -71,6 +71,7 @@ function CompositionRoot.new(options) coordinator = coordinator, facade = facade, activation = nil, + last_highlight_refresh = nil, } return root end @@ -82,14 +83,27 @@ end function CompositionRoot:activate() local record = root_records[self] if record.activation == nil then + local highlights = record.feedback:evaluate_highlights() + local colorscheme_registration = record.host:register_events( + "ColorScheme", + function() + record.last_highlight_refresh = record.feedback:evaluate_highlights() + end, + { owner = "clever_f", lifecycle = "colorscheme" } + ) record.activation = { state = record.state, - highlights = record.feedback:evaluate_highlights(), + highlights = highlights, + colorscheme_registration = colorscheme_registration, } end return record.activation end +function CompositionRoot:last_highlight_refresh() + return root_records[self].last_highlight_refresh +end + function CompositionRoot:host() return root_records[self].host end diff --git a/tests/run.lua b/tests/run.lua index f9e46f2..555faad 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -7105,6 +7105,28 @@ test("Core activation evaluates default and enabled feature highlights", functio same("CleverFDefaultLabel", groups.CleverFDirect.link) end) +test("Core activation refreshes highlights after colorscheme changes", function() + fresh_sequence_state() + local host = MemoryHost.new({ + configuration = { mark_char = true }, + }) + local root = composition_root.new({ host = host }) + local activation = root:activate() + local registration = host:event_registrations()[ + activation.colorscheme_registration + ] + + list_same({ "ColorScheme" }, registration.names) + same("colorscheme", registration.options.lifecycle) + host:set_configuration("mark_char_color", "Search") + host:deliver_event("ColorScheme", {}) + + local refresh = root:last_highlight_refresh() + truthy(refresh ~= nil) + same("configured", refresh.feature_links.CleverFChar.source) + same("Search", host:highlight_groups().CleverFChar.link) +end) + test("Primary coordination accepts only the four motion descriptors", function() local coordinator = sequence_coordinator.new({ host = MemoryHost.new() }) for _, value in ipairs({ "f", "F", "t", "T" }) do |
