[−][src]Trait rucline::completion::Suggester
Generates a list of possible values for the prompt
buffer, usually associated with the
Tab
key.
Whenever the Suggest
action is triggered, the prompt
will ask the
Suggester
for a list of values to replace to the current buffer.
This list is kept by the prompt
for cycling back and forth until it is dropped by
either accepting a suggestion or canceling it. The implementation
may use the Buffer
to decide which completions are applicable.
The buffer is not actually changed until the suggestion is accepted by either a Write
, a
Delete
, Accept
or a Move
, while a suggestion is selected.
See also
Required methods
fn suggest_for(&self, buffer: &Buffer) -> Vec<Cow<'_, str>>
Whenever the Suggest
action is triggered, the prompt
will call suggest_for
for a list of values to replace to the current buffer.
Examples
Basic implementation:
fn suggest_for(&self, _: &Buffer) -> Vec<Cow<'_, str>> { self.0.iter().map(Into::into).collect() }
Arguments
buffer
- Read-only view into the line buffer, providing the context in which this event is happening.
Return
- The list of suggestions to be rendered as drop-down options. Empty if none.