fix surrogate singles. stop using bad surrogate double for testing.
see 2eb57cc725
This commit is contained in:
parent
582831e5bc
commit
cb9ffee1e3
|
@ -1209,7 +1209,6 @@ Screen.prototype.draw = function(start, end) {
|
|||
// If this is a surrogate pair double-width char, we can ignore it
|
||||
// because parseContent already counted it as length=2.
|
||||
point = unicode.codePointAt(line[x][1], 0);
|
||||
if (point <= 0x00ffff) {
|
||||
cwid = unicode.charWidth(point);
|
||||
if (cwid === 2) {
|
||||
// Might also need: `line[x + 1][0] !== line[x][0]`
|
||||
|
@ -1230,7 +1229,6 @@ Screen.prototype.draw = function(start, end) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Attempt to use ACS for supported characters.
|
||||
// This is not ideal, but it's how ncurses works.
|
||||
|
@ -2079,7 +2077,6 @@ Screen.prototype.screenshot = function(xi, xl, yi, yl, term) {
|
|||
|
||||
if (this.fullUnicode) {
|
||||
point = unicode.codePointAt(line[x][1], 0);
|
||||
if (point <= 0x00ffff) {
|
||||
cwid = unicode.charWidth(point);
|
||||
if (cwid === 2) {
|
||||
if (x === xl - 1) {
|
||||
|
@ -2089,7 +2086,6 @@ Screen.prototype.screenshot = function(xi, xl, yi, yl, term) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out += ch;
|
||||
attr = data;
|
||||
|
@ -2432,12 +2428,9 @@ Element.prototype.parseContent = function(noTags) {
|
|||
if (this.screen.fullUnicode) {
|
||||
// double-width chars will eat the next char after render. create a
|
||||
// blank character after it so it doesn't eat the real next char.
|
||||
content = content.replace(unicode.chars.wide, '$1\x03');
|
||||
content = content.replace(unicode.chars.all, '$1\x03');
|
||||
// VTE cannot display double-width chars that are also
|
||||
// surrogate pairs: It miscalculates the width of the chars.
|
||||
if (this.screen.program.isVTE) {
|
||||
content = content.replace(unicode.chars.swide, '??');
|
||||
}
|
||||
} else {
|
||||
// no double-width: replace them with question-marks.
|
||||
content = content.replace(unicode.chars.all, '??');
|
||||
|
@ -2744,14 +2737,14 @@ main:
|
|||
j--;
|
||||
if (line[j] === ' '
|
||||
|| line[j] === '\x03'
|
||||
|| unicode.isSurrogate(line, j - 1)
|
||||
|| (unicode.isSurrogate(line, j - 1) && line[j + 1] !== '\x03')
|
||||
|| unicode.combining[line[j]]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (line[j] === ' '
|
||||
|| line[j] === '\x03'
|
||||
|| unicode.isSurrogate(line, j - 1)
|
||||
|| (unicode.isSurrogate(line, j - 1) && line[j + 1] !== '\x03')
|
||||
|| unicode.combining[line[j]]) {
|
||||
i = j + 1;
|
||||
}
|
||||
|
@ -2796,31 +2789,6 @@ main:
|
|||
: current;
|
||||
}, 0);
|
||||
|
||||
// Find all surrogate pairs and compensate for the lack of width
|
||||
// on the line by padding with trailing spaces:
|
||||
if (this.screen.fullUnicode) {
|
||||
for (var i = 0; i < out.length; i++) {
|
||||
// NOTE: Happens at 54 cols with all chars enabled in test.
|
||||
// Check to see if surrogates got split on end and beginning of 2 lines.
|
||||
if (/[\ud800-\udbff]$/.exec(out[i])
|
||||
&& /^[\udc00-\udfff]/.exec(out[i + 1])) {
|
||||
out[i] = out[i] + out[i + 1][0];
|
||||
out[i + 1] = out[i + 1].substring(1) + ' ';
|
||||
}
|
||||
// Pad the end of the lines if the surrogate is not a double-width char.
|
||||
// var surrogates = out[i].length - punycode.ucs2.decode(out[i]).length;
|
||||
var surrogates = out[i].match(unicode.chars.surrogate);
|
||||
if (surrogates && surrogates.length) {
|
||||
for (var j = 0; j < surrogates.length; j++) {
|
||||
var cwid = unicode.charWidth(surrogates[j], 0);
|
||||
if (cwid === 1) {
|
||||
out[i] += ' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
};
|
||||
|
||||
|
|
|
@ -22,11 +22,15 @@ var DOUBLE = DU + JUAN;
|
|||
|
||||
// var SURROGATE_DOUBLE = '𰀀';
|
||||
// var SURROGATE_DOUBLE = String.fromCharCode(0xD880, 0xDC00);
|
||||
var SURROGATE_DOUBLE = unicode.fromCodePoint(0x30000);
|
||||
// var SURROGATE_DOUBLE = unicode.fromCodePoint(0x30000);
|
||||
|
||||
// var SURROGATE_DOUBLE_OTHER = '🉐';
|
||||
// var SURROGATE_DOUBLE_OTHER = String.fromCharCode(0xD83C, 0xDE50);
|
||||
var SURROGATE_DOUBLE_OTHER = unicode.fromCodePoint(0x1F250);
|
||||
// var SURROGATE_DOUBLE = '𠀀';
|
||||
// var SURROGATE_DOUBLE = String.fromCharCode(0xd840, 0xdc00);
|
||||
var SURROGATE_DOUBLE = unicode.fromCodePoint(0x20000);
|
||||
|
||||
// var SURROGATE_DOUBLE = '🉐';
|
||||
// var SURROGATE_DOUBLE = String.fromCharCode(0xD83C, 0xDE50);
|
||||
// var SURROGATE_DOUBLE = unicode.fromCodePoint(0x1F250);
|
||||
|
||||
// var SURROGATE_SINGLE = '𝌆';
|
||||
// var SURROGATE_SINGLE = String.fromCharCode(0xD834, 0xDF06);
|
||||
|
|
Loading…
Reference in New Issue