From 62b1003a052ff9f22b054a7c23fa2e3c08e63d73 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 15 Apr 2015 10:49:43 -0700 Subject: [PATCH] handle 0-width surrogates. --- lib/widget.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/widget.js b/lib/widget.js index 40978ff..ad409b7 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -2673,7 +2673,10 @@ main: var surrogates = out[i].match(/[\ud800-\udbff][\udc00-\udfff]/g); if (surrogates && surrogates.length) { for (var j = 0; j < surrogates.length; j++) { - if (east_asian_width.char_width(surrogates[j].codePointAt(0)) === 1) { + var cwid = east_asian_width.char_width(surrogates[j].codePointAt(0)); + if (cwid === 0) { + out[i] += ' '; + } else if (cwid === 1) { out[i] += ' '; } }