[READ-ONLY] Mirror of https://github.com/bombshell-dev/clack. Effortlessly build beautiful command-line apps bomb.sh/docs/clack/basics/getting-started/
cli command-line command-line-app node prompt prompts
5

Configure Feed

Select the types of activity you want to include in your feed.

fix: hard wrap and clamp lines in limit-options (#398)

authored by

James Garbutt and committed by
GitHub
(Sep 23, 2025, 9:33 AM +0100) aea4573c 73b88da8

+15 -4
+5
.changeset/better-hotels-fall.md
··· 1 + --- 2 + "@clack/prompts": patch 3 + --- 4 + 5 + Clamp scrolling windows to 5 rows.
+1 -1
packages/prompts/package.json
··· 50 50 "scripts": { 51 51 "build": "unbuild", 52 52 "prepack": "pnpm build", 53 - "test": "FORCE_COLOR=1 vitest run" 53 + "test": "vitest run" 54 54 }, 55 55 "dependencies": { 56 56 "@clack/core": "workspace:*",
+5 -2
packages/prompts/src/limit-options.ts
··· 46 46 const paramMaxItems = params.maxItems ?? Number.POSITIVE_INFINITY; 47 47 const outputMaxItems = Math.max(rows - rowPadding, 0); 48 48 // We clamp to minimum 5 because anything less doesn't make sense UX wise 49 - const maxItems = Math.max(paramMaxItems, 5); 49 + const maxItems = Math.max(Math.min(paramMaxItems, outputMaxItems), 5); 50 50 let slidingWindowLocation = 0; 51 51 52 52 if (cursor >= maxItems - 3) { ··· 73 73 slidingWindowLocationEnd - (shouldRenderBottomEllipsis ? 1 : 0); 74 74 75 75 for (let i = slidingWindowLocationWithEllipsis; i < slidingWindowLocationEndWithEllipsis; i++) { 76 - const wrappedLines = wrapAnsi(style(options[i], i === cursor), maxWidth).split('\n'); 76 + const wrappedLines = wrapAnsi(style(options[i], i === cursor), maxWidth, { 77 + hard: true, 78 + trim: false, 79 + }).split('\n'); 77 80 lineGroups.push(wrappedLines); 78 81 lineCount += wrappedLines.length; 79 82 }
+1 -1
packages/prompts/test/limit-options.test.ts
··· 103 103 output.rows = 7; 104 104 options.maxItems = 10; 105 105 const result = limitOptions(options); 106 - expect(result).toEqual(['Item 1', 'Item 2', 'Item 3', color.dim('...')]); 106 + expect(result).toEqual(['Item 1', 'Item 2', color.dim('...')]); 107 107 }); 108 108 109 109 test('handle multi-line item clamping (start)', async () => {
+3
packages/prompts/vitest.config.ts
··· 2 2 3 3 export default defineConfig({ 4 4 test: { 5 + env: { 6 + FORCE_COLOR: '1', 7 + }, 5 8 snapshotSerializers: ['vitest-ansi-serializer'], 6 9 }, 7 10 });