<commit_before>local search_utils = require "search_utils"
local tables = require "__flib__.table"
local gui = require "__flib__.gui"
local function add_to_table(results, type)
    return function(v, k)
        table.insert(results, { type = type, name = k, localised_name = v.localised_name })
    end
end

local plugin = {
    options_type = "signals",
    options_search = function(force, text)
        local filtered_items = tables.filter(game.item_prototypes, function(_, key) return search_utils.name_contains(key, text) end)
        local filtered_fluids = tables.filter(game.fluid_prototypes, function(_, key) return search_utils.name_contains(key, text) end)
        local filtered_signals = tables.filter(game.virtual_signal_prototypes, function(_, key) return search_utils.name_contains(key, text) end)

        local results = {}
        tables.for_each(filtered_items, add_to_table(results, "item"))
        tables.for_each(filtered_fluids, add_to_table(results, "fluid"))
        tables.for_each(filtered_signals, add_to_table(results, "signal"))
        return results
    end,
    options_render = function(context, results)
        for _, v in pairs(results) do
            local sprite_button = context.parent.add {
                type = "sprite-button",
                name = "signals_result__" .. v.type .. "_" .. v.name,
                style = "slot_button",
                sprite = v.type .. "/" .. v.name
            }
            sprite_button.tooltip = v.localised_name
        end
        gui.update_filters("small_search_window.choose_things.result_button", context.player.index, {"signals_result"}, "add")
    end
}

return plugin
<commit_msg>Search Engine: Fix searching for signals<commit_after>local search_utils = require "search_utils"
local tables = require "__flib__.table"
local gui = require "__flib__.gui"
local function add_to_table(results, type)
    return function(v, k)
        table.insert(results, { type = type, name = k, localised_name = v.localised_name })
    end
end

local plugin = {
    options_type = "signals",
    options_search = function(force, text)
        local filtered_items = tables.filter(game.item_prototypes, function(_, key) return search_utils.name_contains(key, text) end)
        local filtered_fluids = tables.filter(game.fluid_prototypes, function(_, key) return search_utils.name_contains(key, text) end)
        local filtered_signals = tables.filter(game.virtual_signal_prototypes, function(_, key) return search_utils.name_contains(key, text) end)

        local results = {}
        tables.for_each(filtered_items, add_to_table(results, "item"))
        tables.for_each(filtered_fluids, add_to_table(results, "fluid"))
        tables.for_each(filtered_signals, add_to_table(results, "virtual-signal"))
        return results
    end,
    options_render = function(context, results)
        for _, v in pairs(results) do
            local sprite_button = context.parent.add {
                type = "sprite-button",
                name = "signals_result__" .. v.type .. "_" .. v.name,
                style = "slot_button",
                sprite = v.type .. "/" .. v.name
            }
            sprite_button.tooltip = v.localised_name
        end
        gui.update_filters("small_search_window.choose_things.result_button", context.player.index, {"signals_result"}, "add")
    end
}

return plugin

{'fraction_non_alphanumeric': 0.10635155096011817, 'fraction_numerical': 0.0, 'mean_word_length': 3.0844390832328106, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5759015', 'n_tokens_mistral': 1023, 'n_tokens_neox': 992, 'n_words': 221}