diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index 59b842a..f4b9cd6 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -1171,6 +1171,10 @@ class USERPREF_PT_addons(Panel): 'TESTING': 'MOD_EXPLODE', } + # Class var is not ideal (becomes useless in case more than one addons panel is used), + # but should be good enough in most cases! + _search_cache = ["", set()] + @classmethod def poll(cls, context): userpref = context.user_preferences @@ -1201,6 +1205,26 @@ class USERPREF_PT_addons(Panel): for l in lines[1:]: box.label(l) + def filter_search_addons(self, search, addons): + old_search, results = self._search_cache + if not search: + for addon in addons: + yield addon + elif old_search != search: + results.clear() + self._search_cache[0] = search + for addon in addons: + mod, info = addon + if (search in info["name"].lower() or + (info["author"] and search in info["author"].lower()) or + (info["description"] and search in info["description"].lower())): + results.add(mod.__name__) + yield addon + else: + for addon in addons: + if addon[0].__name__ in results: + yield addon + def draw(self, context): import os import addon_utils @@ -1249,7 +1273,7 @@ class USERPREF_PT_addons(Panel): # initialized on demand user_addon_paths = [] - for mod, info in addons: + for mod, info in self.filter_search_addons(search, addons): module_name = mod.__name__ is_enabled = module_name in used_ext @@ -1265,13 +1289,6 @@ class USERPREF_PT_addons(Panel): (filter == "User" and (mod.__file__.startswith((scripts_addons_folder, userpref_addons_folder)))) ): - if search and search not in info["name"].lower(): - if info["author"]: - if search not in info["author"].lower(): - continue - else: - continue - # Addon UI Code col_box = col.column() box = col_box.box()