diff options
| author | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 11:37:38 +0200 |
|---|---|---|
| committer | Jackson Moore <jacksonmoore@tuta.io> | 2026-09-04 11:37:38 +0200 |
| commit | 846277adf74fe59367b4c76280ed76fce10d1528 (patch) | |
| tree | 906a2f13a44e5cee9c5b5efeaed56c445b583175 | |
| parent | e8c73c0c45d439abd06f3b7bdf29e7f6962ae665 (diff) | |
Gate feature link evaluation
| -rw-r--r-- | lua/clever_f/feedback_service.lua | 54 | ||||
| -rw-r--r-- | tests/run.lua | 34 |
2 files changed, 61 insertions, 27 deletions
diff --git a/lua/clever_f/feedback_service.lua b/lua/clever_f/feedback_service.lua index 80824af..81f913f 100644 --- a/lua/clever_f/feedback_service.lua +++ b/lua/clever_f/feedback_service.lua @@ -103,39 +103,41 @@ function FeedbackService:evaluate_feature_links() local results = {} for _, group in ipairs(FEATURE_GROUPS) do local rule = rules[group] - if rule.configured_target ~= nil then - record.host:define_highlight_group( - group, - { link = rule.configured_target }, - { force = true } - ) - results[group] = { - group = group, - target = rule.configured_target, - source = "configured", - applied = true, - } - else - local existing = record.host:read_highlight_group(group) - if existing ~= nil then - results[group] = { - group = group, - definition = existing, - source = "colorscheme", - applied = false, - } - else + if rule.enabled then + if rule.configured_target ~= nil then record.host:define_highlight_group( group, - { link = rule.target }, - { default = true } + { link = rule.configured_target }, + { force = true } ) results[group] = { group = group, - target = rule.target, - source = "fallback", + target = rule.configured_target, + source = "configured", applied = true, } + else + local existing = record.host:read_highlight_group(group) + if existing ~= nil then + results[group] = { + group = group, + definition = existing, + source = "colorscheme", + applied = false, + } + else + record.host:define_highlight_group( + group, + { link = rule.target }, + { default = true } + ) + results[group] = { + group = group, + target = rule.target, + source = "fallback", + applied = true, + } + end end end end diff --git a/tests/run.lua b/tests/run.lua index ba5acd1..77551e1 100644 --- a/tests/run.lua +++ b/tests/run.lua @@ -4368,7 +4368,9 @@ test("Cursor feedback falls back to the Cursor group", function() end) test("Character and direct feedback fall back to the default label", function() - local host = MemoryHost.new() + local host = MemoryHost.new({ + configuration = { mark_direct = true }, + }) local feedback = feedback_service.new(host) local results = feedback:evaluate_feature_links() @@ -4379,6 +4381,36 @@ test("Character and direct feedback fall back to the default label", function() end end) +test("Feature links are evaluated only while their features are enabled", function() + local host = MemoryHost.new({ + configuration = { + mark_cursor = false, + mark_cursor_color = "Search", + mark_char = false, + mark_char_color = "IncSearch", + mark_direct = false, + mark_direct_color = "ErrorMsg", + }, + highlight_groups = { + CleverFCursor = { guifg = "one" }, + CleverFChar = { guifg = "two" }, + CleverFDirect = { guifg = "three" }, + }, + }) + local feedback = feedback_service.new(host) + + local results = feedback:evaluate_feature_links() + same(0, map_size(results)) + local groups = host:highlight_groups() + same("one", groups.CleverFCursor.guifg) + same("two", groups.CleverFChar.guifg) + same("three", groups.CleverFDirect.guifg) + for _, operation in ipairs(host:operations()) do + falsy(operation.operation == "define_highlight_group") + falsy(operation.operation == "read_highlight_group") + end +end) + for _, item in ipairs(tests) do local ok, failure = xpcall(item.body, debug.traceback) if not ok then |
