fix(bidi): isolate leading and inline English words in RTL paragraphs

- In parseInlineSource, wrap consecutive Latin/LTR tokens in LTR isolates (LRI...PDI)
  when rendering inside an RTL block, preventing leading English terms like "Okay"
  from flipping paragraph layout direction and causing BiDi line shuffling.
- Switch textDirection from TextDirection.ContentOrRtl to explicit TextDirection.Rtl
  when isRtl is true across MarkdownText, ChatBubble, and GroupChatScreen, preventing
  first-strong character fallbacks from overriding resolved paragraph direction.
This commit is contained in:
M57 committed 2026-09-04 23:22:22 +03:00
1 parent 199771b798
commit 5ce01e429b
4 files changed
+50 -15

No files matched your search

@@ -563,4 +563,12 @@ class MarkdownTextFeatureTest {
val parsed = parseInline(input, Color.Black, "", false, Color.Blue, DEFAULT_HIGHLIGHTS)
assertEquals("Run val x = 1 here", parsed.toString())
}
@Test
fun testArabicStartingWithEnglishWord_wrapsEnglishInLtrIsolate() {
val input = "Okay سكرت كلشي وصار كامل عربي متل ما بدك يا بوبو"
val parsed = parseInline(input, Color.Black, "", false, Color.Blue, DEFAULT_HIGHLIGHTS)
val expected = "${BidiUtils.LRI}Okay${BidiUtils.PDI} سكرت كلشي وصار كامل عربي متل ما بدك يا بوبو"
assertEquals(expected, parsed.toString())
}
}