Skip to content
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

refactor(Paginator): extract filtering of text input into Func #275

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brianebeling
Copy link

@brianebeling brianebeling commented Mar 17, 2024

Adds a new constructor parameter that accepts a function for filtering text input (i.e. how text is filtered when typing into a Select or MultiSelect Prompt). This allows developers to override the default behavior (in this case .Contains(keyword)) with custom behavior such as fuzzy matching. This helps with long inputs, where you may have multiple keywords or matches in your string but are unsure about the order or exact input.

Motivation

I wanted to use Sharprompt to develop an internal tool, where I wanted to prompt the user to select one or multiple work items from a DevOps board. Sometimes it helps to filter with a text input such as "deliv closed" to match the row "Title: Delivery Menu, Type: User Story, State: Closed" or similar. For my own use case I would like a fuzzy match akin to fzf but was unable to implement that because the behavior is hardcoded into the paginator.

The PR may not be perfect, so I created it as a draft. What are your thoughts on this?

Adds a new constructor parameter that accepts a function for filtering text input (i.e. how text is filtered when typing into a Select or MultiSelect Prompt).
This allows developers to override the default behavior (.Contains(keyword)) with custom behavior such as fuzzy matching. This helps with long inputs, where you may have multiple items in your strings but are unsure about the order or exact input.
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.

1 participant