diff --git a/lib/rules_inline/state_inline.mjs b/lib/rules_inline/state_inline.mjs index 8d33819..35d77d5 100644 --- a/lib/rules_inline/state_inline.mjs +++ b/lib/rules_inline/state_inline.mjs @@ -119,10 +119,11 @@ StateInline.prototype.scanDelims = function (start, canSplitWord) { // treat beginning of the line as a whitespace if (pos <= 0) { return 0x20 } const charCode = str.charCodeAt(pos - 1) - // not low surrogates (BMP) + // not a low-surrogate code unit (is BMP code point) if ((charCode & 0xFC00) !== 0xDC00) { return charCode } - // undefined if out of range (leading stray low surrogates) + // undefined if out of range (typically due to isolated low-surrogate code unit + // at the beginning of the string) const codePoint = str.codePointAt(pos - 2) // undefined > 0xffff = false, so we don't need extra check here return codePoint > 0xffff ? codePoint : charCode