Preserve grapheme clusters in upper corner completion suggester highlighting
authortjones <tjones@wikimedia.org>
Mon, 19 Aug 2019 18:23:33 +0000 (14:23 -0400)
committerBartosz Dziewoński <matma.rex@gmail.com>
Thu, 29 Aug 2019 21:38:44 +0000 (23:38 +0200)
commit6281a389c2dd2c646fb8df6c36041d711925d363
tree557b2536dbee00aabd99a13e0a973b62c0679f1b
parent3de88a71176d088de68c7c776d89d449fcad830c
Preserve grapheme clusters in upper corner completion suggester highlighting

Grapheme clusters in Indic scripts can be split by highlighting,
resulting in really ugly text in the suggestions. For example,
म +  े should equal मे, but doesn't if highlighting markup comes between
the two characters. Affected scripts include Devanagari, Tamil, Telegu,
Thai, Myanmar, Khmer, and Javanese, and probably others. Latin and
Cyrillic script also have the problem, but the presentation is not as
bad (at least on some browser/OS combinations).

- Define a comboMarks regex (equivalent to \p{Mark} in other programming
languages) and use it in a new highlighting function,
prefixPlusComboHighlight, to include trailing combining characters in
highlighted text.

- Change the calling function to use prefixPlusComboHighlight instead of
prefixHighlight.

Note: This only fixes problems with **grapheme clusters** in
suggestions in the **search box in the upper corner** (upper right in
LTR languages, upper left in RTL languages). The main search box on the
Special:Search page uses different code. Ligatures, such as
Arabic ي + ا becoming يا, are not covered by this simple regex-based
solution.

Bug: T35242
Change-Id: I915c50180bc2196e0302f27835241624b7837f16
resources/src/jquery/jquery.highlightText.js
resources/src/jquery/jquery.suggestions.js