From 040bf04cbb4603603f29f3210dcdee05e9b779ef Mon Sep 17 00:00:00 2001 From: Dave Severns <149429124+dseverns-livefront@users.noreply.github.com> Date: Tue, 17 Dec 2024 14:36:58 -0500 Subject: [PATCH] =?UTF-8?q?PM-15976=20=F0=9F=8D=92=20=20prevent=20app=20cr?= =?UTF-8?q?ash=20for=20non=20english=20language=20(#4485)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Phil Cappelli <150719757+phil-livefront@users.noreply.github.com> --- .../java/com/x8bit/bitwarden/ui/platform/base/util/Text.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/base/util/Text.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/base/util/Text.kt index 5ec407b4d7..4efcade16a 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/base/util/Text.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/base/util/Text.kt @@ -199,6 +199,12 @@ fun createClickableAnnotatedString( mainString.lastIndexOf(text, ignoreCase = true) } } + + // Skip adding the link if the text to highlight is not found in the main string. + // This can happen if the highlighted text is correctly translated, but the main string + // is not yet translated, causing the startIndex to be -1. + if (startIndex < 0) continue + val endIndex = startIndex + highlight.textToHighlight.length val link = LinkAnnotation.Clickable( tag = highlight.textToHighlight,