Skip to content

fix: respect withGuide option in password and path prompts#460

Open
kaigritun wants to merge 6 commits intobombshell-dev:mainfrom
kaigritun:fix/withguide-spacing-password-path
Open

fix: respect withGuide option in password and path prompts#460
kaigritun wants to merge 6 commits intobombshell-dev:mainfrom
kaigritun:fix/withguide-spacing-password-path

Conversation

@kaigritun
Copy link

Summary

When withGuide: false is set, the password and path prompts incorrectly included leading whitespace in:

  • User input text
  • Validation error messages

Changes

packages/prompts/src/password.ts

  • Makes indent spacing conditional on hasGuide in the error state
  • When hasGuide: false, no leading whitespace is added to masked text or error message

packages/prompts/src/autocomplete.ts (used by path)

  • Imports settings from @clack/core
  • Adds hasGuide check using opts.withGuide ?? settings.withGuide
  • Makes all guide bar prefixes and spacing conditional on hasGuide
  • Adjusts columnPadding for options based on guide presence

Testing

All 579 tests pass (pnpm build && pnpm test).

Fixes #458

When withGuide: false, password and path (autocomplete) prompts had
incorrect leading whitespace in:
- User input text
- Validation error messages

This commit:
- password.ts: Makes indent spacing conditional on hasGuide
- autocomplete.ts: Adds full withGuide support using settings import

Fixes bombshell-dev#458
@changeset-bot
Copy link

changeset-bot bot commented Feb 5, 2026

🦋 Changeset detected

Latest commit: 4990757

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

This PR includes changesets to release 1 package
Name Type
@clack/prompts 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

const options = this.options;
const placeholder = opts.placeholder;
const showPlaceholder = userInput === '' && placeholder !== undefined;
const indent = hasGuide ? ' ' : '';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't need this. all other prompts include the indent in the prefix (as it is part of the prefix).

it should be more like:

const label = selected.length > 0 ? color.dim(selected.map(getLabel).join(', ')) : '';
const submitPrefix = hasGuide ? `${color.gray(S_BAR)}  ` : '';
return `${headings.join('\n')}\n${submitPrefix}${label}`;

Kai Gritun added 3 commits February 5, 2026 06:07
Move the indent spacing into the prefix for error/submit/cancel cases
in password prompt, matching the pattern used by other prompts.

Updated snapshots accordingly.
@kaigritun
Copy link
Author

Updated to include the indent in the prefix as suggested. All tests passing with updated snapshots.

];
const footers = hasGuide
? [
`${guidePrefix}${color.dim(instructions.join(' • '))}`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the guidePrefix is already empty if it has no guide, so can this be simplified:

const footers = [
  `${guidePrefix}${color.dim(instructions.join(' • '))}`,
  guidePrefixEnd
`;

"<erase.down>",
"◇ Select a fruit
│",
│ ",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't seem right 👀

@kaigritun
Copy link
Author

Fixed both issues:

  1. Simplified footers - removed the hasGuide conditional since guidePrefix is already empty when there's no guide
  2. Fixed double-dim - the instructions array already had color.dim() applied, so wrapping the join in another color.dim() was causing the [2m[2m issue in snapshots. Now only dim the separator: instructions.join(color.dim(' • '))

All tests passing with updated snapshots.

@kaigritun
Copy link
Author

Fixed the trailing spaces issue - moved the indent back into the label/userInputText rather than the prefix, so there are no trailing spaces when the value is empty (e.g., cancel without typing anything). Snapshots updated.

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.

[Bug] incorrect spacing in password and path validation state with withGuide: false

2 participants