Skip to content

fix: Off-by-one symbol range for headings ending with supplementary Unicode characters#455

Merged
artempyanykh merged 1 commit intomainfrom
fix/453-emoji-heading-range
Feb 8, 2026
Merged

fix: Off-by-one symbol range for headings ending with supplementary Unicode characters#455
artempyanykh merged 1 commit intomainfrom
fix/453-emoji-heading-range

Conversation

@artempyanykh
Copy link
Copy Markdown
Owner

Summary

  • Use Char.IsHighSurrogate instead of Char.IsSurrogate in sourceSpanToRange to fix incorrect end offset for supplementary Unicode characters (e.g. emoji)

Test plan

  • Regression test no453 in ParserTests.fs

Fixes #453

…nicode characters

Use Char.IsHighSurrogate instead of Char.IsSurrogate when computing the
end offset in sourceSpanToRange. When a span ends on a low surrogate
(the second code unit of a surrogate pair), adding 2 produces an
out-of-bounds position. Adding 1 is correct since the position already
points to the last code unit.

Fixes #453
@artempyanykh artempyanykh merged commit 4340227 into main Feb 8, 2026
3 checks passed
@artempyanykh artempyanykh deleted the fix/453-emoji-heading-range branch February 8, 2026 20:53
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.

off-by-one symbol range for headings ending with emoji

1 participant