avoid wrapping shortfall due to surrogate pairs.
This commit is contained in:
parent
092b240ef6
commit
ba4108445a
|
@ -2846,6 +2846,17 @@ main:
|
|||
} else {
|
||||
// Try to find a character to break on.
|
||||
if (i !== line.length) {
|
||||
// <XXX>
|
||||
// Compensate for surrogate length
|
||||
// counts on wrapping (experimental):
|
||||
// NOTE: Could optimize this by putting
|
||||
// it in the parent for loop.
|
||||
if (unicode.isSurrogate(line, i)) i--;
|
||||
for (var s = 0, n = 0; n < i; n++) {
|
||||
if (unicode.isSurrogate(line, n)) s++, n++;
|
||||
}
|
||||
i += s;
|
||||
// </XXX>
|
||||
j = i;
|
||||
// Break _past_ space.
|
||||
// Break _past_ double-width chars.
|
||||
|
|
Loading…
Reference in New Issue