diff options
Diffstat (limited to 'cli/js/web/console_table.ts')
-rw-r--r-- | cli/js/web/console_table.ts | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/cli/js/web/console_table.ts b/cli/js/web/console_table.ts index dc22433af..55808cdc0 100644 --- a/cli/js/web/console_table.ts +++ b/cli/js/web/console_table.ts @@ -2,6 +2,7 @@ // Forked from Node's lib/internal/cli_table.js import { hasOwnProperty } from "./util.ts"; +import { stripColor } from "../colors.ts"; const tableChars = { middleMiddle: "─", @@ -19,12 +20,6 @@ const tableChars = { middle: " │ ", }; -const colorRegExp = /\u001b\[\d\d?m/g; - -function removeColors(str: string): string { - return str.replace(colorRegExp, ""); -} - function isFullWidthCodePoint(code: number): boolean { // Code points are partially derived from: // http://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt @@ -65,7 +60,7 @@ function isFullWidthCodePoint(code: number): boolean { } function getStringWidth(str: string): number { - str = removeColors(str).normalize("NFC"); + str = stripColor(str).normalize("NFC"); let width = 0; for (const ch of str) { |