Skip to content

Commit

Permalink
Hide Modules in Search
Browse files Browse the repository at this point in the history
Gorp
  • Loading branch information
machiecodes committed Jan 8, 2025
1 parent 58190ab commit 064e9b1
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,16 @@ public Set<Module> searchTitles(String text) {
Map<Module, Integer> modules = new ValueComparableMap<>(Comparator.naturalOrder());

for (Module module : this.moduleInstances.values()) {
if (Config.get().hiddenModules.get().contains(module)) continue;

int score = Utils.searchLevenshteinDefault(module.title, text, false);
if (Config.get().moduleAliases.get()) {
for (String alias : module.aliases) {
int aliasScore = Utils.searchLevenshteinDefault(alias, text, false);
if (aliasScore < score) score = aliasScore;
}
}

modules.put(module, modules.getOrDefault(module, 0) + score);
}

Expand All @@ -189,13 +192,16 @@ public Set<Module> searchSettingTitles(String text) {
Map<Module, Integer> modules = new ValueComparableMap<>(Comparator.naturalOrder());

for (Module module : this.moduleInstances.values()) {
if (Config.get().hiddenModules.get().contains(module)) continue;

int lowest = Integer.MAX_VALUE;
for (SettingGroup sg : module.settings) {
for (Setting<?> setting : sg) {
int score = Utils.searchLevenshteinDefault(setting.title, text, false);
if (score < lowest) lowest = score;
}
}

modules.put(module, modules.getOrDefault(module, 0) + lowest);
}

Expand Down

0 comments on commit 064e9b1

Please sign in to comment.