From 4637c4069ee2ba47214c32a20eb8cbf240ae1799 Mon Sep 17 00:00:00 2001 From: 4di-hello <4di-hello@users.noreply.github.com> Date: Sun, 22 Nov 2026 11:11:02 +0100 Subject: [PATCH] Settings search: also find parts of words MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The search only found words starting with the search term. In languages with compound words (German "Löschtaste", "Autokorrektur") and for words like "Autocorrect", a part in the middle was not found. Terms of 3 or more letters now also find settings whose title or description contains them; these results come after the existing ones. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01VuiaMhLXwhErf9shhrr1uD --- .../helium314/keyboard/settings/SettingsContainer.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/helium314/keyboard/settings/SettingsContainer.kt b/app/src/main/java/helium314/keyboard/settings/SettingsContainer.kt index 97f328e5c..cca71c75d 100644 --- a/app/src/main/java/helium314/keyboard/settings/SettingsContainer.kt +++ b/app/src/main/java/helium314/keyboard/settings/SettingsContainer.kt @@ -53,10 +53,11 @@ class SettingsContainer(context: Context) { // show as disabled (i.e. no interaction possible) -> users confused // show, but change will not do anything because another setting needs to be enabled first -> probably best fun filter(searchTerm: String): List { - val term = searchTerm.lowercase() + val term = searchTerm.lowercase().trim() val titleMatch = mutableListOf() val titleWordMatch = mutableListOf() val descriptionMatch = mutableListOf() + val partialMatch = mutableListOf() list.forEach { setting -> val titleLower = setting.titleLower @@ -66,10 +67,13 @@ class SettingsContainer(context: Context) { titleWordMatch.add(setting) } else if (setting.descriptionWords?.any { it.startsWith(term) } == true) { descriptionMatch.add(setting) + } else if (term.length >= 3 && (titleLower.contains(term) || setting.descriptionLower?.contains(term) == true)) { + // parts of compound words, e.g. "taste" in the German "Löschtaste", or "correct" in "Autocorrect" + partialMatch.add(setting) } } - return titleMatch + titleWordMatch + descriptionMatch + return titleMatch + titleWordMatch + descriptionMatch + partialMatch } } @@ -95,7 +99,8 @@ class Setting( val titleLower = title.lowercase() val titleWords = titleLower.split(' ') - val descriptionWords = description?.lowercase()?.split(' ') + val descriptionLower = description?.lowercase() + val descriptionWords = descriptionLower?.split(' ') @Composable fun Preference() {