Comments (5)
@fribeau v0.3.0-alpha-2 is now up :)
from inquire.
Hey @fribeau.
Actually, we don't have the tab
assigned to anything on this prompt. What I believe you're seeing in the demo was that I pressed down arrow
to move the cursor to the first suggestion, then the prompt auto-updated the text field to the highlighted suggestion.
You bring a very good point on usability though, the tab key is widely known as associated to auto-completion, so I think it is a usability problem for us to not use it. I'm thinking of assigning tab
to either use the first suggestion in the list
, if none are selected, or update text field to the current highlighted suggestion
, which would basically remove other suggestions.
from inquire.
Thanks for this quick reply and for this awesome crate 😉
I also think handling tab
would be really a great feature.
Regarding the tab
assignment you proposing, I know that for my use case it would not work as expected. I am trying to implement a path
autocomplete so I am trying to reproduce the same behavior I am getting in the terminal (with bash
for example).
If I have the following directory structure and the input is /bar/f
I would expect /bar/foo
when the user press the tab
key, but not necessary the first result (/bar/foo1
).
/bar
/foo1
/foo2
Another approach could be:
- if only 1 suggestion remain -> complete with it
- if many -> complete with the longest prefix available
But maybe my use case it too specific
from inquire.
Yeah I think that's a little too specific for the library.
The suggestion-er behavior is implemented by the user, which means that if we hard-coded the completion process to something implementation-specific, it would break other use-cases, for example fuzzy searching and searching by substrings instead of prefixes, from the top of my mind.
What we could do instead is to have a default implementation (complete with the first option), but then provide the ability for the user to provide a hook, e.g. "auto_complete(cur_input: &str) -> String". Then you could do:
auto_complete = |cur_input| {
// return string with longest prefix that matches input
}
Then, the prompt would call your method, get what auto-completion string and replace the current input with your completion.
There are still a few details on how to make this works seamlessly with the current "suggestion" system, but it is a direction forward :)
from inquire.
Hey @mikaelmello
I have tried several implementations trying to come up with a good solution to this problem. I finally ended up with the solution you proposed 😉 It is a good one because it is really simple so it can really be customized to the user needs.
I opened a PR to showcase this feature. You're welcome to criticize, I am completely open to suggestions.
from inquire.
Related Issues (20)
- Release HOT 1
- Use tty instead of stdin HOT 1
- with_starting_cursor does not apply HOT 2
- Fully support piped inputs in parallel with interactive inputs.
- Prompt crashes if program is run with crossterm+piped input+macos
- Add code coverage metrics to get a better idea of test coverage
- inquire derive and attribute macro HOT 3
- Show proper error message for CustomType prompt HOT 1
- Alt+{left, right, backspace} support HOT 3
- DateSelect default help message incorrect ? HOT 2
- Support for up-arrow previous prompt history, and control-keys HOT 2
- Inquire leaves the terminal in a broken state HOT 3
- Render issue using the `console` backend HOT 2
- Inquire forgets to add newlines in 0.7.1 HOT 5
- "external_print" Functionality
- Make Scrolling More Obvious (Customizable maybe?) HOT 1
- MultiSelect list doesn't show after filter is cleared on selection HOT 1
- Suppressing static lifetimes from Text (and other modules ?) HOT 1
- typo in README for termion link
- Password prompt with redirected `stdout`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from inquire.