From 51cd38450abedfcb495efe604636ea27e65c3871 Mon Sep 17 00:00:00 2001 From: lgjint <78463565+lgjint@users.noreply.github.com> Date: Mon, 3 Jun 2024 22:20:19 +0800 Subject: [PATCH] fix: inline suggestions in keyboard only show ''Select entry'' Kunzisoft/KeePassDX#1708 --- .../com/kunzisoft/keepass/autofill/AutofillHelper.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/kunzisoft/keepass/autofill/AutofillHelper.kt b/app/src/main/java/com/kunzisoft/keepass/autofill/AutofillHelper.kt index 501043c7a..4fc0c399e 100644 --- a/app/src/main/java/com/kunzisoft/keepass/autofill/AutofillHelper.kt +++ b/app/src/main/java/com/kunzisoft/keepass/autofill/AutofillHelper.kt @@ -60,6 +60,7 @@ import com.kunzisoft.keepass.settings.AutofillSettingsActivity import com.kunzisoft.keepass.settings.PreferencesUtil import com.kunzisoft.keepass.utils.LOCK_ACTION import com.kunzisoft.keepass.utils.getParcelableExtraCompat +import kotlin.math.min @RequiresApi(api = Build.VERSION_CODES.O) @@ -321,10 +322,11 @@ object AutofillHelper { val inlinePresentationSpecs = inlineSuggestionsRequest.inlinePresentationSpecs val maxSuggestion = inlineSuggestionsRequest.maxSuggestionCount - if (positionItem <= maxSuggestion - 1 - && inlinePresentationSpecs.size > positionItem - ) { - val inlinePresentationSpec = inlinePresentationSpecs[positionItem] + if (positionItem <= maxSuggestion - 1) { + + // If positionItem is larger than the number of specs in the list, then + // the last spec is used for the remainder of the suggestions + val inlinePresentationSpec = inlinePresentationSpecs[min(positionItem, inlinePresentationSpecs.size - 1)] // Make sure that the IME spec claims support for v1 UI template. val imeStyle = inlinePresentationSpec.style