Allow selections to wrap around

This commit is contained in:
Salvage
2022-09-25 01:23:05 +02:00
committed by Phil Scott
parent eb02c3d534
commit 4f0ec87522
7 changed files with 181 additions and 6 deletions

View File

@ -18,6 +18,12 @@ public sealed class MultiSelectionPrompt<T> : IPrompt<List<T>>, IListPromptStrat
/// </summary>
public int PageSize { get; set; } = 10;
/// <summary>
/// Gets or sets whether the selection should wrap around when reaching the edge.
/// Defaults to <c>false</c>.
/// </summary>
public bool WrapAround { get; set; } = false;
/// <summary>
/// Gets or sets the highlight style of the selected choice.
/// </summary>
@ -88,7 +94,7 @@ public sealed class MultiSelectionPrompt<T> : IPrompt<List<T>>, IListPromptStrat
{
// Create the list prompt
var prompt = new ListPrompt<T>(console, this);
var result = await prompt.Show(Tree, cancellationToken, PageSize).ConfigureAwait(false);
var result = await prompt.Show(Tree, cancellationToken, PageSize, WrapAround).ConfigureAwait(false);
if (Mode == SelectionMode.Leaf)
{