Skip to content

fix: account for escape sequences in prefixes - #631

Open
43081j wants to merge 1 commit into
mainfrom
jg/ansi-witchcraft
Open

43081j wants to merge 1 commit into
mainfrom
jg/ansi-witchcraft

Conversation

@43081j

@43081j 43081j commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

This is a known bug we've had for quite some time. Basically, we were
checking prefix.length to calculate how much space the prefix (e.g.
the guide) takes up.

This is incorrect since the prefix usually contains escape sequences, so
it can be off by several characters. Using fast-string-width instead
means we get the actual width.

Note that fast-string-width is already a deep dependency, so this just
declares it at the root.

As part of this, I also wrapped the footer of select-like prompts FYI.

Type of change

  • Bug fix
  • Feature
  • Refactor (no behavior change)
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • I have added a changeset

AI-generated code disclosure

  • This PR includes AI-generated code

This is a known bug we've had for quite some time. Basically, we were
checking `prefix.length` to calculate how much space the prefix (e.g.
the guide) takes up.

This is incorrect since the prefix usually contains escape sequences, so
it can be off by several characters. Using fast-string-width instead
means we get the actual width.

Note that fast-string-width is already a deep dependency, so this just
declares it at the root.
@changeset-bot

changeset-bot Bot commented Oct 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3cdb798

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@clack/prompts Patch
@clack/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Oct 29, 2026

Copy link
Copy Markdown

commit: 3cdb798

@43081j
43081j requested a review from dreyfus92 October 29, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant