Skip to content

Commit

Permalink
(#1363) fix rendering of ListPrompt for odd pageSizes
Browse files Browse the repository at this point in the history
  • Loading branch information
nils-a authored and patriksvensson committed Jan 1, 2024
1 parent 006da0f commit 6f1f299
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Spectre.Console/Prompts/List/ListPrompt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ private IRenderable BuildRenderable(ListPromptState<T> state)
skip = Math.Max(0, state.Index - middleOfList);
take = Math.Min(pageSize, state.ItemCount - skip);

if (state.ItemCount - state.Index < middleOfList)
if (take < pageSize)
{
// Pointer should be below the end of the list
var diff = middleOfList - (state.ItemCount - state.Index);
// Pointer should be below the middle of the (visual) list
var diff = pageSize - take;
skip -= diff;
take += diff;
cursorIndex = middleOfList + diff;
Expand Down

0 comments on commit 6f1f299

Please sign in to comment.