From 6f1f29967da73938997fa8d2646bdc534721e04b Mon Sep 17 00:00:00 2001 From: Nils Andresen Date: Tue, 14 Nov 2023 00:38:22 +0100 Subject: [PATCH] (#1363) fix rendering of ListPrompt for odd pageSizes --- src/Spectre.Console/Prompts/List/ListPrompt.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Spectre.Console/Prompts/List/ListPrompt.cs b/src/Spectre.Console/Prompts/List/ListPrompt.cs index f30f4d348..5db80c2d2 100644 --- a/src/Spectre.Console/Prompts/List/ListPrompt.cs +++ b/src/Spectre.Console/Prompts/List/ListPrompt.cs @@ -89,10 +89,10 @@ private IRenderable BuildRenderable(ListPromptState 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;