Repository navigation
Description
Environment
- OS: Linux
- Node Version: v26.13.0
- Package:
@clack/prompts - Package Version: 1.9.0 (also reproduces on
mainat 50c8ea0)
Describe the bug
In a narrow terminal, autocompleteMultiselect renders a frame taller than the terminal. The top rows scroll away, the redraw can't move the cursor back above the top row, and each keypress leaves stale copies of earlier rows (old Search: lines, old options) above the prompt.
The option list is sized from rows - rowPadding, but rowPadding counts the header and footer lines before they wrap. When the message or the instructions line (↑/↓ to navigate • Tab: select • Enter: confirm • Type: to search) wraps, the list gets more rows than are actually free. autocompleteMultiselect also doesn't pass columnPadding to limitOptions, so options are measured 3 columns wider than the space left after the │ guide prefix.
autocomplete has the same row under-count for a wrapped message or instructions line. It overflows less often because it already passes columnPadding and its instructions line is shorter.
select and multiselect already wrap the message with wrapTextWithPrefix and the instructions with formatInstructionFooter (#631) before counting rows.
To Reproduce
// repro.mjs, with "@clack/prompts": "1.9.0"
import { autocompleteMultiselect } from '@clack/prompts';
await autocompleteMultiselect({
message: 'Which languages would you like to translate your project into?',
options: Array.from({ length: 50 }, (_, i) => ({ value: `opt${i}`, label: `Option ${i}` })),
});- Resize the terminal to 60x24.
- Run
node repro.mjs. - Type
o,p, then Backspace.
Replaying the prompt's output on a 60x24 virtual terminal shows 2 rows scrolled off after these keystrokes. With the locale list from our CLI (longer labels), it reaches 9 rows.
Expected behavior
The frame fits the terminal height, and redraws replace the previous frame in place, as multiselect does.
Additional Information
Found in the gt CLI (generaltranslation/gt#2654), which currently caps both prompts with maxItems: 8 as a workaround.
Measured with a virtual terminal that replays the prompt output (scrolls past the bottom row, clamps cursor-up at the top row), with the default maxItems:
| Terminal | autocomplete |
autocompleteMultiselect |
|---|---|---|
| 100x30 | fits | fits |
| 80x24 | fits | fits |
| 60x24 | fits | overflows |
| 60x20 | fits | overflows |
| 60x16 | fits | overflows |
(autocomplete fits here only because the message used in that test is shorter than 60 columns. With a message that wraps, it overflows too. See the regression test in the linked PR.)
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNeeds triage
Activity