Skip to content

Commit 360afeb

Browse files
committed
feat: adaptative max items
1 parent 90f8e3d commit 360afeb

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

.changeset/light-laws-judge.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clack/prompts': patch
3+
---
4+
5+
feat: adaptative max items

packages/prompts/src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
SelectKeyPrompt,
99
SelectPrompt,
1010
State,
11-
TextPrompt
11+
TextPrompt,
1212
} from '@clack/core';
1313
import isUnicodeSupported from 'is-unicode-supported';
1414
import color from 'picocolors';
@@ -69,7 +69,8 @@ const limitOptions = <TOption>(params: LimitOptionsParams<TOption>): string[] =>
6969
const { cursor, options, style } = params;
7070

7171
// We clamp to minimum 5 because anything less doesn't make sense UX wise
72-
const maxItems = params.maxItems === undefined ? Infinity : Math.max(params.maxItems, 5);
72+
const maxItems =
73+
params.maxItems === undefined ? process.stdout.rows - 4 : Math.max(params.maxItems, 5);
7374
let slidingWindowLocation = 0;
7475

7576
if (cursor >= slidingWindowLocation + maxItems - 3) {

0 commit comments

Comments
 (0)