Filter selection prompt items with search #1797
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #1546
Changes
I changed the code so that now when a user searches, the list is filtered down to only those items which match the search term
ListPromptState.cs
There are now 3 lists which hold the current state of the prompt:
Items
This existed before and contains all the itemsVisibleItems
This list contains only items which match the search term, or any groups which contain a child which matches the search term_selectableItems
This list contains only the subset ofVisibleItems
which are selectable (ie. not a group if in leaf mode, following the same logic as before with_leafIndexes
). it is a list ofSelectableItem
which contains theListPromptItem
and also the index of the item inVisibleItems
.VisibleItems
and_selectableItems
are updated every time the search term changes, when the user is navigates the list the only the index of the item in_selectableItems
is updated (which is stored in_selectableIndex
).ListPrompt.cs
VisibleItems
filterOnSearch
SelectionPrompt.cs
FilterOnSearch
propertystate.Current == null
. This happens when theVisibleItems
is filtered to the point it contains no itemsSelectionPromptExtensions.cs
EnableSearch
method to setFilterOnSearch
MultiSelectionPrompt.cs
filterOnSearch
IListPromptStrategy
Please upvote 👍 this pull request if you are interested in it.