Skip to content

Fix Select prompt failing to accept exact match when items share a common prefix#326

Merged
shibayan merged 4 commits intomasterfrom
copilot/fix-single-selection-function
Mar 5, 2026
Merged

Fix Select prompt failing to accept exact match when items share a common prefix#326
shibayan merged 4 commits intomasterfrom
copilot/fix-single-selection-function

Conversation

Copy link
Contributor

Copilot AI commented Feb 26, 2026

  • Fix Paginator.TryGetSelectedItem to auto-select an item when the filter keyword is an exact (case-insensitive) match, even if other items also contain the keyword as a substring
  • Add tests for the exact-match auto-select scenario (exact match, case-insensitive match, no exact match)
  • Resolve merge conflicts with master's new tests in PaginatorTests.cs
  • All 163 tests pass (including 16 new tests from master)
Original prompt

This section details on the original issue you should resolve

<issue_title>Error in single selection from a string array</issue_title>
<issue_description>Dear Tatsuro Shibamura,

it came to my attention that the selection function which offers the single selection
form an array of strings doesn't work if two or more of the strings start with the
same substring.

Image

Please take a look at your own sample program. There you have two pair of strings
which start with the same substring.
"Select" & "SelectWithEnum" and
"MultiSelect" & "MultiSelectWithEnum".

You will not be able to select one of this strings of the former mentioned string
pairs.

Image Image

Kind regards,

G. Poehlmann.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…re a common prefix

Co-authored-by: shibayan <1356444+shibayan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error in single selection from string array Fix Select prompt failing to accept exact match when items share a common prefix Feb 26, 2026
@shibayan
Copy link
Owner

shibayan commented Mar 5, 2026

@copilot Please resolve conflicts

… new tests

Co-authored-by: shibayan <1356444+shibayan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 5, 2026

@copilot Please resolve conflicts

Resolved in 9cc7a30. The conflict was in PaginatorTests.cs where both master's new tests (#329) and our 3 exact-match tests were appended at the same location. I pulled in master's version and appended our tests after. All 163 tests pass.

@shibayan shibayan marked this pull request as ready for review March 5, 2026 02:49
@shibayan shibayan requested a review from Copilot March 5, 2026 02:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a Sharprompt Select prompt edge case where typing a filter that exactly matches an item (case-insensitive) fails to allow selection when other items share the same prefix (e.g., Select vs SelectWithEnum).

Changes:

  • Update Paginator.TryGetSelectedItem to auto-select an exact (case-insensitive) match of FilterKeyword even when multiple filtered items exist.
  • Add unit tests covering exact match, case-insensitive exact match, and no exact match scenarios.
  • Resolve test merge conflicts in PaginatorTests.cs and keep the suite passing.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Sharprompt/Internal/Paginator.cs Adds exact-match selection fallback when no explicit selection exists.
Sharprompt.Tests/PaginatorTests.cs Adds regression tests for exact-match auto-selection behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@shibayan shibayan merged commit 0714eff into master Mar 5, 2026
9 checks passed
@shibayan shibayan deleted the copilot/fix-single-selection-function branch March 5, 2026 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error in single selection from a string array

3 participants