Skip to content

feat: highlight autocomplete suggestion when it matches typed word#648

Draft
Mounil2005 wants to merge 7 commits into
scribe-org:mainfrom
Mounil2005:feat/highlight-exact-completion-match
Draft

feat: highlight autocomplete suggestion when it matches typed word#648
Mounil2005 wants to merge 7 commits into
scribe-org:mainfrom
Mounil2005:feat/highlight-exact-completion-match

Conversation

@Mounil2005

Copy link
Copy Markdown
Contributor

Contributor checklist

  • This pull request is on a separate branch and not the main branch
  • I have tested my code with the ./gradlew lintKotlin detekt test command as directed in the testing section of the contributing guide

Description

Once the user has typed enough of a word that the first autocomplete suggestion exactly matches it (e.g. typing "Buch" when "Buch" is itself a suggestion), that suggestion chip is now highlighted (bold, accent blue text) to indicate that tapping it is effectively a no-op, matching the existing Scribe-iOS behavior described in the issue.

  • app/src/keyboards/java/be/scri/services/GeneralKeyboardIME.kt: setSuggestionButton and setAutocompleteButton now accept the word currently being typed. If a suggestion's text exactly matches it (case-insensitive), the button is rendered bold using R.color.theme_scribe_blue instead of the default text color. Tap behavior is unchanged — it still deletes the current word and re-inserts the suggestion (a no-op when they're equal).
  • app/src/keyboards/java/be/scri/helpers/AutocompletionHandler.kt: passes the current word through to updateAutocompleteSuggestions so the exact-match check has what it needs.

Tested by running ./gradlew lintKotlin detekt test (all green) and ./gradlew :app:compileKeyboardsDebugKotlin.

Related issue

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

Thank you for the pull request! 💙🩵

The Scribe-Android team will do our best to address your contribution as soon as we can. The following are some important points:

  • Those interested in developing their skills and expanding their role in the community should read the mentorship and growth section of the contribution guide
  • If you're not already a member of our public Matrix community, please consider joining!
    • We'd suggest that you use the Element client as well as Element X for a mobile app
    • Join the General and Android rooms once you're in
  • Also consider attending our bi-weekly Saturday developer syncs!
    • Details are shared in the General room on Matrix each Wednesday before the sync
    • It would be great to meet you 😊

Note

Scribe uses Conventional Comments in reviews to make sure that communication is as clear as possible.

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

Maintainer Checklist

The following is a checklist for maintainers to make sure this process goes as well as possible. Feel free to address the points below yourself in further commits if you realize that actions are needed :)

  • Tests for changes have been written and the unit test, linting and formatting workflows within the PR checks do not indicate new errors in the files changed

    • Tests may need to be reran as they're at times not deterministic
  • The CHANGELOG has been updated with a description of the changes for the upcoming release and the corresponding issue (if necessary)

@andrewtavis

Copy link
Copy Markdown
Member

praise: Thanks so much for the PR, @Mounil2005! We'll try to get to the review in the coming days :)

note: For UI changes like this, would you be able to send along a screenshot that includes the change? If it's something like this, then maybe there's no need for a screenshot of the state before the change, but before and after screenshots are also quite helpful as a reviewer in knowing that the work has been completed before going into the code. Just suggesting! 😊

Co-authored-by: Priyanshikaa1111 <Priyanshikaa1111@gmail.com>
Signed-off-by: Mounil Kanakhara <mounilkankhara@gmail.com>
@Mounil2005 Mounil2005 force-pushed the feat/highlight-exact-completion-match branch from 2ec0e10 to e19e0a1 Compare July 6, 2026 18:45
Co-authored-by: Priyanshikaa1111 <Priyanshikaa1111@gmail.com>
Signed-off-by: Mounil Kanakhara <mounilkankhara@gmail.com>
@Mounil2005

Copy link
Copy Markdown
Contributor Author

While testing this locally with Scribe German, I found that the native dictionary engine
(NativeSuggestionEngine.getAutocompletions) explicitly filters out the exact typed word from its completions, it's designed to only suggest extensions of what you've typed (e.g. typing Buch only returned buchen, Buchhändler, Bücherei, never Buch itself). That meant the highlight-on-exact-match feature could never actually trigger through the primary suggestion path, since the exact match never reached the UI.

Rather than removing that filter (which would make "exact match shows first" dependent on the native dictionary's internal ranking, not guaranteed), I used the dictionary's existing isValidWord/isInDictionary check separately: if what the user has typed is itself a real word, it's now always shown as the first suggestion, with the remaining slots filled by real completions, deterministically matching the behavior in the issue's screenshot rather than hoping the ranking happens to put it first.

Tested on-device (emulator) with Scribe German across several words (Buch, Haus, Auto, Zeit, and various prefixes)...the exact match consistently shows first and highlighted (bold, accent blue) whenever it's a valid word, while non-exact prefixes correctly show only extensions with no highlight.

Screenshot 2026-07-07 032903 Screenshot 2026-07-07 032934 Screenshot 2026-07-07 033007

@andrewtavis

Copy link
Copy Markdown
Member

note @Mounil2005, @@Priyanshikaa1111: I'm thinking that it might be for the best if we move the word that the user is typing to the first autocompletion sole and just change the background to be highlighted rather than the text being blue. This at least is a common behavior in iOS keyboards. Specifically what this allows us to do is also have a space functionality where when the word is highlighted, pressing space will insert it.

The way that this works in Scribe-iOS is the following:

  • Say that we have an English words registry with the words "house", "houses", "drum" and "dolphin"
  • The user types "hous" and "house" is the first autocomplete, but not highlighted
  • The user types "e" and "house" is the first autocomplete (not really an autocomplete anymore) and is highlighted
  • There's really no difference to pressing space here
  • If the user types "do", then "dolphin" is the only word that can follow
  • The word "dolphin" is now the first autocomplete
  • If the user presses space, then we'd insert "dolphin" in this case as it was highlighted
  • We'd also make "do" the first autocomplete for if the user actually did want to type the word that they'd typed and just wanted a space instead of an autocomplete

The example above of "do" -> "dolphin" would never happen, so this example is mainly for larger words where once a user types enough of it, then it's obvious that they're typing it and we might as well insert the rest on space for them. The indication that this is going to happen is the autosuggestion being highlighted :)

How does this sound to the both of you?

CC @angrezichatterbox for this discussion 👋

Mounil2005 and others added 3 commits July 8, 2026 23:52
…blue text

Co-authored-by: Priyanshikaa1111 <Priyanshikaa1111@gmail.com>
Signed-off-by: Mounil Kanakhara <mounilkankhara@gmail.com>
Co-authored-by: Priyanshikaa1111 <Priyanshikaa1111@gmail.com>
Signed-off-by: Mounil Kanakhara <mounilkankhara@gmail.com>
Co-authored-by: Priyanshikaa1111 <Priyanshikaa1111@gmail.com>
Signed-off-by: Mounil Kanakhara <mounilkankhara@gmail.com>
@Mounil2005

Copy link
Copy Markdown
Contributor Author

note @Mounil2005, @@Priyanshikaa1111: I'm thinking that it might be for the best if we move the word that the user is typing to the first autocompletion sole and just change the background to be highlighted rather than the text being blue. This at least is a common behavior in iOS keyboards. Specifically what this allows us to do is also have a space functionality where when the word is highlighted, pressing space will insert it.

The way that this works in Scribe-iOS is the following:

  • Say that we have an English words registry with the words "house", "houses", "drum" and "dolphin"
  • The user types "hous" and "house" is the first autocomplete, but not highlighted
  • The user types "e" and "house" is the first autocomplete (not really an autocomplete anymore) and is highlighted
  • There's really no difference to pressing space here
  • If the user types "do", then "dolphin" is the only word that can follow
  • The word "dolphin" is now the first autocomplete
  • If the user presses space, then we'd insert "dolphin" in this case as it was highlighted
  • We'd also make "do" the first autocomplete for if the user actually did want to type the word that they'd typed and just wanted a space instead of an autocomplete

The example above of "do" -> "dolphin" would never happen, so this example is mainly for larger words where once a user types enough of it, then it's obvious that they're typing it and we might as well insert the rest on space for them. The indication that this is going to happen is the autosuggestion being highlighted :)

How does this sound to the both of you?

CC @angrezichatterbox for this discussion 👋

That sounds great, thanks for the detailed writeup! I've implemented all three pieces:

  1. Background highlight instead of blue text: the highlighted suggestion now shows a rounded, tinted background box behind the text, matching the Scribe-iOS reference image, instead of the bold blue text from the first version of this PR.
  2. Highlighted suggestion always in the first slot + space inserts it: pressing space now checks if a suggestion is highlighted and, if so, inserts it (with a trailing space) in place of the word being typed, instead of just committing a literal space.
  3. Broader trigger for "obvious" completions: highlighting no longer only fires when the user has typed a word out in full. If only one dictionary word can possibly complete what's been typed so far (the do → dolphin case), that word is now promoted to the first slot and highlighted, while what the user actually typed (do) is still offered as another suggestion in case they wanted to keep typing their own word.

I'll be attaching images shortly to show this working end-to-end.

@Mounil2005 Mounil2005 marked this pull request as draft July 8, 2026 18:40
Mounil2005 and others added 2 commits July 9, 2026 17:06
Co-authored-by: Priyanshikaa1111 <Priyanshikaa1111@gmail.com>
Signed-off-by: Mounil Kanakhara <mounilkankhara@gmail.com>
Co-authored-by: Priyanshikaa1111 <Priyanshikaa1111@gmail.com>
Signed-off-by: Mounil Kanakhara <mounilkankhara@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Highlight autocompletion if it is the word the user is typing

2 participants