From 051e90070c1bc4bf51fe0a9cdd553e140eeb2f06 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sun, 26 Apr 2015 07:03:52 -0700 Subject: [PATCH] workaround VTEs wide surrogate pair display bug. --- lib/widget.js | 8 ++++++++ test/widget-eaw.js | 1 + 2 files changed, 9 insertions(+) diff --git a/lib/widget.js b/lib/widget.js index 4659aae..1115180 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -2425,6 +2425,14 @@ Element.prototype.parseContent = function(noTags) { // 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'); + // 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, '?'); + } } else { // no double-width: replace them with question-marks. content = content.replace(unicode.chars.all, '??'); diff --git a/test/widget-eaw.js b/test/widget-eaw.js index ac79c1b..a16f2ae 100644 --- a/test/widget-eaw.js +++ b/test/widget-eaw.js @@ -93,6 +93,7 @@ lorem = lorem.replace(/e/gi, DOUBLE); //lorem = lorem.replace(/r/gi, JUAN); // NOTE: libvte breaks when trying to display // this surrogate pair double width character: +// if (!~process.argv.indexOf('vte') && !screen.program.isVTE) { if (!~process.argv.indexOf('vte')) { lorem = lorem.replace(/a/gi, SURROGATE_DOUBLE); }