(#1363) fix rendering of ListPrompt for odd pageSizes

This commit is contained in:
Nils Andresen 2023-11-14 00:38:22 +01:00 committed by Patrik Svensson
parent 006da0f9ea
commit 6f1f29967d

View File

@ -89,10 +89,10 @@ internal sealed class ListPrompt<T>
skip = Math.Max(0, state.Index - middleOfList); skip = Math.Max(0, state.Index - middleOfList);
take = Math.Min(pageSize, state.ItemCount - skip); 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 // Pointer should be below the middle of the (visual) list
var diff = middleOfList - (state.ItemCount - state.Index); var diff = pageSize - take;
skip -= diff; skip -= diff;
take += diff; take += diff;
cursorIndex = middleOfList + diff; cursorIndex = middleOfList + diff;