Skip to content

Commit

Permalink
fix: calculate box width without escape sequence chars
Browse files Browse the repository at this point in the history
  • Loading branch information
xxhls committed Jan 8, 2025
1 parent 3190635 commit 32f85d1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export function box(text: string, _opts: BoxOpts = {}) {
opts.style.padding % 2 === 0 ? opts.style.padding : opts.style.padding + 1;
const height = textLines.length + paddingOffset;
const width =
Math.max(...textLines.map((line) => line.length)) + paddingOffset;
Math.max(...textLines.map((line) => stripAnsi(line).length)) + paddingOffset;
const widthOffset = width + paddingOffset;

const leftSpace =
Expand Down

0 comments on commit 32f85d1

Please sign in to comment.