Skip to content

fix: complete global source maps and Arabic ligature spans - #14

Merged
xclud merged 12 commits into
olutter:mainfrom
palmoni5:codex/upstream-bidi-source-maps
Nov 14, 2026
Merged

xclud merged 12 commits into
olutter:mainfrom
palmoni5:codex/upstream-bidi-source-maps

Conversation

@palmoni5

Copy link
Copy Markdown
Contributor

Problem and resulting behavior

logicalToVisual2 omitted paragraph-separator mappings, restarted source indices in each paragraph and left its lengths output empty. For abc\nאבג, upstream main returned indices [0, 1, 2, 2, 1, 0] and no spans; this branch returns [0, 1, 2, 3, 6, 5, 4] with seven spans of length one. Existing caller entries remain intact and new mappings are appended.

Expose aligned per-paragraph sourceLengths and return global UTF-16 source offsets and spans, including separators. Preserve consumed source spans during Arabic lam-alef shaping and close the ligature state so a following alef remains visible. For ل\u064EاX, the old source index of X was 2; it is now correctly 3.

Transparent marks require explicit source indices: a lam-alef glyph spans the entire logical interval from lam through alef, including intervening transparent marks, while those still-visible marks retain their own source indices and one-unit spans. These source intervals intentionally overlap. For ل\u064EاX, the ligature maps to offset 0/span 3, the mark to offset 1/span 1, and X to offset 3/span 1. Normalization.lengths separately accounts for consumed logical source units and preserves its total source length.

Validation

  • Reproduced the preceding paragraph-mapping and transparent-mark failures directly against upstream main (ebef4fb), then confirmed corrected results with this branch.
  • flutter analyze: no issues.
  • dart test: all 14 tests pass, covering multiple separators, formatting controls, canonical composition, caller-owned list append behavior, ordinary Arabic, all four alef variants, joined and isolated ligatures, a second alef, and one or multiple transparent marks with overlapping source spans.

This PR is independently based on upstream main and groups the public visual-to-source mapping contract with the Arabic shaping bookkeeping required to make it correct. Performance, supplementary scalar handling, combining-mark reordering and bracket resolution are submitted separately. No package-version change.

@Y-PLONI

Y-PLONI commented Nov 12, 2026

Copy link
Copy Markdown

בבדיקת הביצועים של תיקון מיפויי המקור נמצא ש־finishLamAlef מסיר את ה־alef מכל שלושת מערכי המיפוי באמצעות removeAt, ולכן קלט צפוף בליגטורות נעשה ריבועי.

הכנתי תיקון המשך המבוסס ישירות על head הנוכחי של PR זה. הוא דוחס את המיפויים והאורכים במעבר קדימה ומקצר את המערכים פעם אחת, תוך שימור מיפוי וטווחי ניקוד שקוף. נוספו בדיקת צפיפות ובנצ׳מרק שחזור. כל 15 בדיקות הענף ו־dart analyze עברו. השוואת 10,000 מחרוזות אקראיות קבועות בשילוב הפורק אימתה זהות של פלט, אינדקסים, טווחי מקור ואורכי נרמול. מדידת AOT מקומית של 10,000 ליגטורות בשילוב ירדה מכ־690 מ״ש לכ־7 מ״ש; זו מדידה סינתטית ולא זמן הדפסה כולל.

לא הייתה הרשאת כתיבה זמינה לענף המקורי ב־palmoni5/bidi, ולכן התיקון פורסם ב־ענף הארגון לצורך יישום באותו PR. הענף עצמאי מ־#13, הענף המקורי לא שונה ולא נפתח PR כפול.

@xclud
xclud merged commit 40b327a into olutter:main Nov 14, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants