From 1ff3b87f5a9ac604c313791821e9bf7e08e2aa1d Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sun, 15 Nov 2026 15:12:23 +0100 Subject: [PATCH] fix: honor Arabic Letter Mark in paragraph direction detection (#2149) Recognize U+061C alongside RLM before the alphabetic-character check. Extend directional-mark coverage to preserve first-strong precedence. --- crates/model/src/bidi.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/model/src/bidi.rs b/crates/model/src/bidi.rs index 0b113522a..1ec52dc76 100644 --- a/crates/model/src/bidi.rs +++ b/crates/model/src/bidi.rs @@ -10,8 +10,8 @@ /// Cyrillic, CJK…) give `false`. Neutral, weak, and whitespace characters are skipped. pub fn first_strong_is_rtl(text: &str) -> bool { for c in text.chars() { - if c == '\u{200F}' { - // Right-to-Left Mark (RLM) + if c == '\u{200F}' || c == '\u{061C}' { + // RLM and ALM are strong RTL controls, although neither is alphabetic. return true; } if c == '\u{200E}' { @@ -76,6 +76,10 @@ mod tests { #[test] fn honours_directional_marks() { assert!(first_strong_is_rtl("\u{200F}Hello")); + assert!(first_strong_is_rtl("\u{061C}Hello")); + assert!(first_strong_is_rtl("\u{061C}")); + assert!(!first_strong_is_rtl("Hello\u{061C}")); + assert!(!first_strong_is_rtl("\u{200E}\u{061C}")); assert!(!first_strong_is_rtl("\u{200E}مرحبا")); } }