Skip to content

Commit

Permalink
fix(cli): cannot scroll down (#11762)
Browse files Browse the repository at this point in the history
* fix: pageStart

* refactor: clean

* refactor: clean
  • Loading branch information
yuqizhou77 authored Jun 4, 2024
1 parent 05361c3 commit e9896e6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/cli/src/prompts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ export function computePrefixWidth(
): number {
const middle = Math.floor(pageSize / 2);
let pageStart;
if (current < middle) pageStart = 0;
else if (current > choices.length - middle)
pageStart = choices.length < pageSize ? 0 : choices.length - pageSize;
else pageStart = current - middle;
if (choices.length <= pageSize) pageStart = 0;
else {
if (current < middle) pageStart = 0;
else if (current > choices.length - middle) pageStart = choices.length - pageSize;
else pageStart = current - middle;
}
let prefixWidth = 1;
choices.slice(pageStart, pageStart + pageSize).forEach((choice) => {
prefixWidth = Math.max(prefixWidth, !choice.title ? 0 : choice.title.length + 1);
Expand Down

0 comments on commit e9896e6

Please sign in to comment.