From 264f71b926a521b6f09055b0b6ef16cead09bd51 Mon Sep 17 00:00:00 2001 From: Ahad Birang Date: Thu, 21 Mar 2019 15:42:16 +0330 Subject: [PATCH 1/2] fix(nested-styling): reopen closed style --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 7d00571..18a4a5c 100644 --- a/index.js +++ b/index.js @@ -162,7 +162,7 @@ const applyStyle = (self, ...arguments_) => { // Replace any instances already present with a re-opening code // otherwise only the part of the string until said closing code // will be colored, and the rest will simply be 'plain'. - string = code.open + string.replace(code.closeRe, code.open) + code.close; + string = code.open + string.replace(code.closeRe, code.close + code.open) + code.close; // Close the styling before a linebreak and reopen // after next line to fix a bleed issue on macOS From a9c8de76d66b0dae1f8748928ebfdb013962fe5f Mon Sep 17 00:00:00 2001 From: Ahad Birang Date: Thu, 21 Mar 2019 16:00:45 +0330 Subject: [PATCH 2/2] chore(test): change nesting styles test --- test/chalk.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/chalk.js b/test/chalk.js index 240f0f9..518be6a 100644 --- a/test/chalk.js +++ b/test/chalk.js @@ -37,7 +37,7 @@ test('support nesting styles', t => { test('support nesting styles of the same type (color, underline, bg)', t => { t.is( chalk.red('a' + chalk.yellow('b' + chalk.green('c') + 'b') + 'c'), - '\u001B[31ma\u001B[33mb\u001B[32mc\u001B[33mb\u001B[31mc\u001B[39m' + '\u001B[31ma\u001B[33mb\u001B[32mc\u001B[39m\u001B[31m\u001B[33mb\u001B[39m\u001B[31mc\u001B[39m' ); });