Fix space triggering selection when items in selection list have a space. (#1881)

* Changes Search in SelectionPrompt to accept Space Key as text

---------

Co-authored-by: Philipp <30900810+DerReparator@users.noreply.github.com>
This commit is contained in:
Mitch Denny
2025-08-20 04:09:12 +10:00
committed by GitHub
parent a8b2f1f1e0
commit 3a6d3e4520
2 changed files with 29 additions and 2 deletions

View File

@@ -109,7 +109,9 @@ public sealed class SelectionPrompt<T> : IPrompt<T>, IListPromptStrategy<T>
/// <inheritdoc/>
ListPromptInputResult IListPromptStrategy<T>.HandleInput(ConsoleKeyInfo key, ListPromptState<T> state)
{
if (key.Key == ConsoleKey.Enter || key.Key == ConsoleKey.Spacebar || key.Key == ConsoleKey.Packet)
if (key.Key == ConsoleKey.Enter
|| key.Key == ConsoleKey.Packet
|| (!state.SearchEnabled && key.Key == ConsoleKey.Spacebar))
{
// Selecting a non leaf in "leaf mode" is not allowed
if (state.Current.IsGroup && Mode == SelectionMode.Leaf)