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

Could not select candidate in pager mode #65

Closed
YangchenYe323 opened this issue Aug 6, 2024 · 3 comments · Fixed by #66
Closed

Could not select candidate in pager mode #65

YangchenYe323 opened this issue Aug 6, 2024 · 3 comments · Fixed by #66
Labels
enhancement New feature or request

Comments

@YangchenYe323
Copy link
Contributor

Hi team, I'm looking to support a paged tab completion for an application I'm building using readline.

I noticed that currently the user cannot select or navigate the candidates in pager mode, which makes it less useful. In chyzer#238 I treated paging as a transparent feature. I did not give it an explicit mode, so the user could navigate as usual in CompletSelection mode with added hotkeys for scrolling through the page.

Below is a demo of what my implementation looks like:

Recording2024-08-05211333-ezgif com-video-to-gif-converter

I'd be happy to submit a PR if this change is welcome, or if there are plans to support selecting in pager mode I'd be happy to hack something that aligns with your preferred design, too.

@slingamn
Copy link
Member

slingamn commented Aug 6, 2024

Hi, this sounds interesting, but I wanted to clarify what you mean by "currently the user cannot select or navigate the candidates in pager mode". If you go run example/readline-demo/readline-demo.go and press the Tab key once, you should see a list of completion options. If you press it a second time, the first option should be visibly selected (as in your demo), and Tab/Shift-Tab and Right/Left should navigate through the options, with Enter choosing the selected option. I can believe that the existing implementation does not scale to the use case you described (~1000 options) but I would like to understand more about what you are proposing to add, and how it differs from what we currently have implemented.

@YangchenYe323
Copy link
Contributor Author

Hi. thanks for your reply.

I can believe that the existing implementation does not scale to the use case you described (~1000 options)

The existing implementation will fall back to pager mode when the number of candidates cannot be shown on a single screen, which looks like this:

image

And in this mode the user could not select the candidate by pressing another Tab or navigating using the arrow keys. I believe this is because the input is intercepted in the HandlePagerMode method, and the mode does not support selecting a candidate from the page.

I would like to understand more about what you are proposing to add, and how it differs from what we currently have implemented.

I think it would be nice to support selecting candidate in the pager mode like I show in my demo, where the user could both navigate the page and use Tab/arrow/enters to select a candidate to put on the buffer.

@slingamn
Copy link
Member

slingamn commented Aug 7, 2024

Oh, now I understand. Yes, a PR for this would be very welcome! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants