-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
Filtering a list where the items contain spaces when using select #161
Comments
Hi Francisco 👋 Thanks for submitting the issue. I had a quick look at implementing this for the |
Interesting! I was thinking that we'd keep the default as is (i.e. space is selection) unless explicitly stated otherwise -- something similar to what I tried above:
Then if the user explicitly does this for Does that make sense? |
Yup, makes sense. I wanted to avoid the need to specify a different key for selection in the |
I can. I'm not super familiar with the structure of the codebase so if you can guide me a little bit where I could add a failing test + where I'd go to work to fix it that'd be a great start! |
Sure thing. The logic responsible for the |
@piotrmurach Any chance you could help me to get a start here? I've downloaded the project but I'm not entirely sure how I'd start tackling this since I'm fairly unfamiliar with the implementation. Even if you can put a branch up with what you had would probably be super helpful! |
Hey all! I stumbled upon the same problem, needing my filters to include spaces. I believe I have implemented what @piotrmurach described in the PR above, including the check for clashing keys in mutli-select. |
As I just encountered the same issue, I work around it with a specific new class and a little monkey patch: class SpaceList < TTY::Prompt::List
def keyspace(event)
@filter << event.value
@active = 1
end
end
module TTY
class Prompt
def select_with_space(question, *args, &block)
invoke_select(SpaceList, question, *args, &block)
end
end
end
prompt = TTY::Prompt.new(interrupt: :exit)
answer = prompt.select_with_space('Select a sentence: ', sentences, filter: true) |
Hey @piotrmurach, is there an estimation when this will be added? This issue exists for years now... @milouse's monkey patch works good for me, but it'd be very nice if |
Describe the problem
I'm trying to find a way to not use the space character as selection when filtering a list using select. I'm using select for a list of names that have spaces in them (e.g
["Some Team", "Some Team: Subteam"]
).When the user types "Some " the prompt selects the first instance and I want it to continue filtering using the space.
I tried using
prompt.select('Select a team name:', team_names, filter: true, keys: [:return])
but that didn't work.Steps to reproduce the problem
Actual behaviour
When the user types "Some " the prompt selects the first instance (i.e.
Some Team
)Expected behaviour
When the user types "Some " the prompt continues filtering using the space.
Describe your environment
The text was updated successfully, but these errors were encountered: