From dc399988417cc1e35d5bc1fc55fce56f0606bdef Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Thu, 24 Aug 2017 22:18:07 -0600 Subject: [PATCH] Fix some breakage caused by word wrapping with ESC seqs --- core/word_wrap.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/word_wrap.js b/core/word_wrap.js index e8b55f8d..0a4b122d 100644 --- a/core/word_wrap.js +++ b/core/word_wrap.js @@ -24,7 +24,13 @@ function wordWrapText2(text, options) { options.tabWidth = options.tabWidth || 4; options.tabChar = options.tabChar || ' '; - const REGEXP_GOBBLE = new RegExp(`.{0,${options.width}}`, 'g'); + //const REGEXP_GOBBLE = new RegExp(`.{0,${options.width}}`, 'g'); + // + // For a given word, match 0->options.width chars -- alwasy include a full trailing ESC + // sequence if present! + // + // :TODO: Need to create ansi.getMatchRegex or something - this is used all over + const REGEXP_GOBBLE = new RegExp(`.{0,${options.width}}\\x1b\\[[\\?=;0-9]*[ABCDEFGHJKLMSTfhlmnprsu]|.{0,${options.width}}`, 'g'); let m; let word;