Fix some breakage caused by word wrapping with ESC seqs

This commit is contained in:
Bryan Ashby 2017-08-24 22:18:07 -06:00
parent d47f26004d
commit dc39998841
1 changed files with 7 additions and 1 deletions

View File

@ -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;