+ // Allow matches to end in the middle of a grapheme cluster if the following
+ // conditions are met; this is needed to make prefix search work properly in
+ // Indic, see #11750
+ // * the default breakIter is being used
+ // * the next collation element after this combining sequence
+ // - has non-zero primary weight
+ // - corresponds to a separate character following the one at end of the current match
+ // (the second of these conditions, and perhaps both, may be redundant given the
+ // subsequent check for normalization boundary; however they are likely much faster
+ // tests in any case)
+ // * the match limit is a normalization boundary
+ UBool allowMidclusterMatch = FALSE;
+ if (strsrch->search->text != NULL && strsrch->search->textLength > maxLimit) {
+ allowMidclusterMatch =
+ strsrch->search->breakIter == NULL &&
+ nextCEI != NULL && (((nextCEI->ce) >> 32) & 0xFFFF0000UL) != 0 &&
+ maxLimit >= lastCEI->highIndex && nextCEI->highIndex > maxLimit &&
+ (strsrch->nfd->hasBoundaryBefore(codePointAt(*strsrch->search, maxLimit)) ||
+ strsrch->nfd->hasBoundaryAfter(codePointBefore(*strsrch->search, maxLimit)));
+ }
+ // If those conditions are met, then:
+ // * do NOT advance the candidate match limit (mLimit) to a break boundary; however
+ // the match limit may be backed off to a previous break boundary. This handles
+ // cases in which mLimit includes target characters that are ignorable with current
+ // settings (such as space) and which extend beyond the pattern match.
+ // * do NOT require that end of the combining sequence not extend beyond the match in CE space
+ // * do NOT require that match limit be on a breakIter boundary
+