-
-
Notifications
You must be signed in to change notification settings - Fork 520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SelectionPrompt
does not search on results of UseConverter
#1626
Comments
Some testing, this test works: [Fact]
public void Should_Search_In_Remapped_Result()
{
// Given
var console = new TestConsole();
console.Profile.Capabilities.Interactive = true;
console.EmitAnsiSequences();
console.Input.PushText("2");
console.Input.PushKey(ConsoleKey.Enter);
var myObject = new List<Tuple<string, string>>
{
new ( "Value", "Item 1" ),
new ( "Value", "Item 2" )
};
// When
var prompt = new SelectionPrompt<Tuple<string, string>>()
.Title("Select one")
.EnableSearch()
.UseConverter(o => o.Item2)
.AddChoices(myObject);
var selection = prompt.Show(console);
// Then
selection.Item2.ShouldBe("Item 2");
} |
Potential fix here: 93e3689 Not sure if there's a better way of doing this, tried to refactor so the function is only called once per item. Will wait for a reply on this issue before creating a PR or anything. |
Thanks for attempting to fix this, but we don't want to change the API. The UseConverter is used to get a representation, so we do not want to add an explicit representation when adding the item (optional or not) since this is what the converter is for. I will look into what is required to fix the search. |
@snus-kin I've submitted a PR that should fix this. Will merge shortly |
@snus-kin This is fixed and is now available in |
Thanks pal, appreciate it |
Tested this on my use-case today and it works perfectly, thanks for the prompt fix 😄 |
Information
Describe the bug
Selection prompts which use
UseConverter
do not jump to the search (they do not use the mapped text as the search index).To Reproduce
You can also search for the underlying object and observe that it is jumped to.
Example unit test that currently fails (where
MyClass
is just a class with a name parameter):Expected behavior
SelectionPrompt should search based on the results of
UseConverter
and not on the underlying object remapped by it. (see test)Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
Add any other context about the problem here.
Please upvote 👍 this issue if you are interested in it.
The text was updated successfully, but these errors were encountered: