Skip to main content

EditorCompletion

Trait EditorCompletion 

Source
pub trait EditorCompletion {
    // Required method
    fn suggest(&mut self, text: &str, cursor: usize) -> Option<Suggestions>;

    // Provided methods
    fn hint(&mut self, text: &str, cursor: usize) -> Option<Str> { ... }
    fn tab(
        &mut self,
        text: &str,
        cursor: usize,
        selected: Option<&Suggestion>,
    ) -> TabAction { ... }
}
Expand description

Pluggable completion engine registered with Editor::set_completion.

The editor consults it after every edit, so an implementation chooses its own trigger convention (/, @, #, or none at all) by inspecting the text before the cursor. SlashCommands is the built-in pi-style implementation.

Required Methods§

Source

fn suggest(&mut self, text: &str, cursor: usize) -> Option<Suggestions>

Dropdown suggestions for the current text and byte cursor, or None to close the dropdown.

Provided Methods§

Source

fn hint(&mut self, text: &str, cursor: usize) -> Option<Str>

Dim ghost text rendered after the cursor (usage hints, AI completion). Re-queried after every edit.

Source

fn tab( &mut self, text: &str, cursor: usize, selected: Option<&Suggestion>, ) -> TabAction

Tab pressed. selected is the highlighted row while this engine’s dropdown is open. Defaults to pi’s behavior: accept the open row, otherwise pass Tab through to the embedding app. The built-in emoji dropdown always accepts without consulting the engine.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§