From 0ea8c77dd817268732156f0f03395665084afdb1 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sun, 26 Apr 2015 07:16:50 -0700 Subject: [PATCH] fix VTE. only remove surrogate double chars. --- lib/unicode.js | 9 +++++++-- lib/widget.js | 5 +---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/unicode.js b/lib/unicode.js index 886e7c0..1c683e7 100644 --- a/lib/unicode.js +++ b/lib/unicode.js @@ -567,13 +567,18 @@ exports.chars.wide = new RegExp('([' + '\\uffe0-\\uffe6' + '])', 'g'); -// All wide chars including surrogate pairs. -exports.chars.all = new RegExp('(' +// All surrogate pair wide chars. +exports.chars.swide = new RegExp('(' // 0x20000 - 0x2fffd: + '[\\ud840-\\ud87f][\\udc00-\\udffd]' + '|' // 0x30000 - 0x3fffd: + '[\\ud880-\\ud8bf][\\udc00-\\udffd]' + + ')', 'g'); + +// All wide chars including surrogate pairs. +exports.chars.all = new RegExp('(' + + exports.chars.swide.source.slice(1, -1) + '|' + exports.chars.wide.source.slice(1, -1) + ')', 'g'); diff --git a/lib/widget.js b/lib/widget.js index 1115180..d3ac64e 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -2428,10 +2428,7 @@ Element.prototype.parseContent = function(noTags) { // VTE cannot display double-width chars that are also // surrogate pairs: It miscalculates the width of the chars. if (this.screen.program.isVTE) { - // In reality we should only drop double-width surrogate pairs, - // but we don't have a regex for that yet. - // content = content.replace(unicode.chars.surrogateDoubleWidth, '?'); - content = content.replace(unicode.chars.surrogate, '?'); + content = content.replace(unicode.chars.swide, '?'); } } else { // no double-width: replace them with question-marks.