maruohon / malilib

Library mod for masa's client-side Minecraft mods
GNU Lesser General Public License v3.0
294 stars 124 forks source link

Fix config category search not working with upper case #67

Closed alex-huff closed 2 years ago

alex-huff commented 2 years ago

Configuration categories that contain Keybinds don't work with search strings that contain upper-case characters. Example: Litematica's Hotkeys, Tweakaroo's Tweaks, Hotkeys, and Yeets.

In Tweakaroo, searching for tweakAccurateBlockPlacement in the Tweaks category yields nothing, while searching for tweakaccurateblockplacement gives the correct result.

WidgetListBase's getFilterText() converts the search bar filter to lower case,

    protected String getFilterText()
    {
        return this.widgetSearchBar != null ? this.widgetSearchBar.getFilter().toLowerCase() : "";
    }

where WidgetListConfigOptions's getFilterText() does not when widgetSearchConfigs is not null.

    @Override
    protected void addFilteredContents(Collection<ConfigOptionWrapper> entries)
    {
        if (this.widgetSearchConfigs != null)
        {
            String filterText = this.widgetSearchConfigs.getFilter(); // should be lower case here
            IKeybind filterKeys = this.widgetSearchConfigs.getKeybind();

            for (ConfigOptionWrapper entry : entries)
            {
                if ((filterText.isEmpty() || this.entryMatchesFilter(entry, filterText)) &&
                    (entry.getConfig().getType() != ConfigType.HOTKEY ||
                     filterKeys.getKeys().size() == 0 ||
                     ((IHotkey) entry.getConfig()).getKeybind().overlaps(filterKeys)))
                {
                    this.listContents.add(entry);
                }
            }
        }
        else
        {
            super.addFilteredContents(entries);
        }
    }