Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/hungry-rice-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clack/prompts": patch
---

Fixes a withGuide rendering issue leaving extra spaces in text prompts.
1 change: 1 addition & 0 deletions packages/core/test/prompts/prompt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ describe('Prompt', () => {
expect(eventSpy).not.toHaveBeenCalled();
expect(instance.state).to.equal('validating');

// biome-ignore lint/style/noNonNullAssertion: We know resolveValidation is defined
resolveValidation!(undefined);
await resultPromise;

Expand Down
2 changes: 1 addition & 1 deletion packages/prompts/src/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const text = (opts: TextOptions) => {
return `${title.trim()}\n${errorPrefix}${userInput}\n${errorPrefixEnd}${errorText}\n`;
}
case 'submit': {
const valueText = value ? ` ${styleText('dim', value)}` : '';
const valueText = value ? `${hasGuide ? ' ' : ''}${styleText('dim', value)}` : '';
const submitPrefix = hasGuide ? styleText('gray', S_BAR) : '';
return `${title}${submitPrefix}${valueText}`;
}
Expand Down
28 changes: 24 additions & 4 deletions packages/prompts/test/__snapshots__/text.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,15 @@ exports[`text (isCI = false) > global withGuide: false removes guide 1`] = `
_

",
"<cursor.backward count=999><cursor.up count=3>",
"<cursor.down count=1>",
"<erase.line><cursor.left count=1>",
"x█",
"<cursor.down count=2>",
"<cursor.backward count=999><cursor.up count=3>",
"<erase.down>",
"◇ foo
",
x",
"
",
"<cursor.show>",
Expand Down Expand Up @@ -339,10 +344,15 @@ exports[`text (isCI = false) > withGuide: false removes guide 1`] = `
_

",
"<cursor.backward count=999><cursor.up count=3>",
"<cursor.down count=1>",
"<erase.line><cursor.left count=1>",
"x█",
"<cursor.down count=2>",
"<cursor.backward count=999><cursor.up count=3>",
"<erase.down>",
"◇ foo
",
x",
"
",
"<cursor.show>",
Expand Down Expand Up @@ -479,10 +489,15 @@ exports[`text (isCI = true) > global withGuide: false removes guide 1`] = `
_

",
"<cursor.backward count=999><cursor.up count=3>",
"<cursor.down count=1>",
"<erase.line><cursor.left count=1>",
"x█",
"<cursor.down count=2>",
"<cursor.backward count=999><cursor.up count=3>",
"<erase.down>",
"◇ foo
",
x",
"
",
"<cursor.show>",
Expand Down Expand Up @@ -688,10 +703,15 @@ exports[`text (isCI = true) > withGuide: false removes guide 1`] = `
_

",
"<cursor.backward count=999><cursor.up count=3>",
"<cursor.down count=1>",
"<erase.line><cursor.left count=1>",
"x█",
"<cursor.down count=2>",
"<cursor.backward count=999><cursor.up count=3>",
"<erase.down>",
"◇ foo
",
x",
"
",
"<cursor.show>",
Expand Down
2 changes: 2 additions & 0 deletions packages/prompts/test/text.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ describe.each(['true', 'false'])('text (isCI = %s)', (isCI) => {
output,
});

input.emit('keypress', 'x', { name: 'x' });
input.emit('keypress', '', { name: 'return' });

await result;
Expand All @@ -232,6 +233,7 @@ describe.each(['true', 'false'])('text (isCI = %s)', (isCI) => {
output,
});

input.emit('keypress', 'x', { name: 'x' });
input.emit('keypress', '', { name: 'return' });

await result;
Expand Down
Loading