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

[Feature Request] Pin selected items on top when using fuzzy multi-select #1

Open
shivams opened this issue Jan 29, 2021 · 5 comments

Comments

@shivams
Copy link

shivams commented Jan 29, 2021

First of all, thanks a lot for this wonderful port. PyInquirer was using many old libraries and had become unusable. Your module comes as a life-saver!

Now, on to the issue (a feature request actually).

Let's say I have a list of 1000 items in my multi-select question. I would want my selected items to be shown (pinned) at the top. It helps to keep track of what has already been selected while doing the fuzzy searching.

@shivams shivams changed the title [Feature Request] Show selected items on top when using fuzzy multi-select [Feature Request] Pin selected items on top when using fuzzy multi-select Jan 29, 2021
@kazhala
Copy link
Owner

kazhala commented Feb 1, 2021

Hi @shivams,

Thanks for using the module. Sorry for the late response.

Regarding the feature request, you'd like to have selected items stick at the top no matter what word is being searched? So like if current choices are ["hello", "world", "foo", "boo"] and you have selected boo, you'd like boo to stick at the top even if the search field has asdfasfadsfas which yields zero available choices?

Please correct me if I misunderstand some of it, its a valid feature request and shouldn't be hard to implement. However, the concern would be what if out of 1000 choices, 100 choices (doesn't have to be this much), the terminal is usually not big enough to display other unselected choices, do you have any ideas or suggestions on the behaviour for this sort of situations? E.g. Terminal only has 20 lines to display, you have selected 21 choices, now there's probably no place to effectively display any non-selected choices.

Cheers,
Kevin

@shivams
Copy link
Author

shivams commented Feb 1, 2021

Hi @kazhala:

Yes. You understood it correctly. This is exactly what I have in mind. Thank you for explaining the feature request with an example.

The Concern

Your concern is valid. One solution could be to limit the visibility of the pinned options (i.e. only show up to, say, 5 items). But this wouldn't really solve the problem (since pinned items may easily go above a given limit).

Another (better) solution, if implementable, would be to have a separate section for pinned items. I am imagining a separate scrollable list of pinned items. In this case, we will then have 2 scrollable sections: one for selecting the items and one which contains selected items. Switching between these 2 sections could be done using TAB key. I have no idea if this is implementable or not.

@kazhala
Copy link
Owner

kazhala commented Feb 1, 2021

Hi @shivams,

I like your second solution, so could be like a split in the middle of all the choices. Left is the normal list of choices and the right split is only the selected choices. Perhaps an optional keybinding to toggle the split and provides keybinding to switch focus.

Should be alright to implement, I'll look into it when I get some time this weekend.

Cheers,
Kevin

@averypierce
Copy link

I've got a more specific version of this ask
basically can there be an option to remove this len() and just display self.selected_choices? And possibly hide the num_selected/num_choices count too.

if self._multiselect:
                display_message.append(
                    ("class:fuzzy_info", f" ({len(self.selected_choices)})")
                )

It could just stay on that line and go off to the right. Once you run out of space, ellipsis. Not perfect in all situations, but better than current behavior in some.

This would be useful in the case that you have many many options, but usually only select a few, less than 5.

Say we selected two options (['apple', 'bacon']), and then searched for 's'. It would be nice if instead of:

? Pick something:  
❯ s 2/13020 (2)
  sandwhich
  steak

it could show:

? Pick something:  
❯ s (['apple', 'bacon'])
  sandwhich
  steak

@averypierce
Copy link

averypierce commented Aug 16, 2022

f" ({list(map(lambda x: x.get('name','value'), self.selected_choices))})" basically does it, but I don't have a way to distribute it.

Gracecr pushed a commit to Gracecr/InquirerPy that referenced this issue Feb 13, 2023
… some issues with factory restore. kazhala#1: ncs and kcs were added and use the SD card so they need to be stopped when formatting, kazhala#2: filesystem sync for df_backend was failing because the system call forks off and wasn't complete when the process was torn down. Made that a fork+exec now, kazhala#3: Cleaned up some of the result keys to be a little cleaner.
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

No branches or pull requests

3 participants