Skip to content
Open
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/multiselect-overflow-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clack/prompts': patch
---

fix: correctly calculate multiselect layout row padding on narrow terminals to prevent option text overflow and visual overwriting
10 changes: 6 additions & 4 deletions packages/prompts/src/multi-select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,9 @@ export const multiselect = <Value>(opts: MultiSelectOptions<Value>) => {
)
.join('\n');
// Calculate rowPadding: title lines + footer lines (error message + trailing newline)
const titleLineCount = title.split('\n').length;
const footerLineCount = footer.split('\n').length + 1; // footer + trailing newline
const titleLineCount = title.split('\n').length - 1;
const wrappedFooter = wrapTextWithPrefix(opts.output, footer, '');
const footerLineCount = wrappedFooter.split('\n').length + 1; // footer + trailing newline
return `${title}${prefix}${limitOptions({
output: opts.output,
options: this.options,
Expand All @@ -184,14 +185,15 @@ export const multiselect = <Value>(opts: MultiSelectOptions<Value>) => {
}
default: {
const prefix = hasGuide ? `${styleText('cyan', S_BAR)} ` : '';
const titleLineCount = title.split('\n').length;
const titleLineCount = title.split('\n').length - 1;
const footerLines = showInstructions
? formatInstructionFooter(MULTISELECT_INSTRUCTIONS, hasGuide)
: hasGuide
? [styleText('cyan', S_BAR_END)]
: [];
const footerText = footerLines.join('\n');
const footerLineCount = footerLines.length + 1;
const wrappedFooter = wrapTextWithPrefix(opts.output, footerText, '');
const footerLineCount = wrappedFooter.split('\n').length + 1;
return `${title}${prefix}${limitOptions({
output: opts.output,
options: this.options,
Expand Down
Loading
Loading