pub enum CompletionStyle {
List(MoveDir1D, bool),
None,
Prefix,
Single,
}Expand description
What type of phrase we are completing.
Variants§
List(MoveDir1D, bool)
Navigate through the list of completion candidates.
The bool argument controls whether to allow toggling back and forth
between the pre-completion state and completion when there is only a
single candidate in the completion list. This is usually desired in
contexts where the user may want to reset back to the prefix if the
completion was not what they wanted.
§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, EditorAction};
let ct = CompletionType::Auto;
let style = CompletionStyle::List(MoveDir1D::Next, true);
let display = CompletionDisplay::List;
let act: Action = EditorAction::Complete(style, ct, display).into();
assert_eq!(act, action!("complete -s (list -d next) -T auto -D list"));
let ct = CompletionType::Auto;
let style = CompletionStyle::List(MoveDir1D::Next, false);
let display = CompletionDisplay::List;
let act: Action = EditorAction::Complete(style, ct, display).into();
assert_eq!(act, action!("complete -s (list -d next --toggle false) -T auto -D list"));None
Generate completion candidates, but don’t select any from the list.
This is most helpful for keybindings that allow the user to get a list of potential candidates that they can read through without actually picking any, in case they don’t know what the first character to type is.
§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, EditorAction};
let ct = CompletionType::Auto;
let style = CompletionStyle::None;
let display = CompletionDisplay::List;
let act: Action = EditorAction::Complete(style, ct, display).into();
assert_eq!(act, action!("complete -s none -T auto -D list"));Prefix
Complete only the longest common prefix from the completion candidates.
§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, EditorAction};
let ct = CompletionType::Auto;
let style = CompletionStyle::Prefix;
let display = CompletionDisplay::List;
let act: Action = EditorAction::Complete(style, ct, display).into();
assert_eq!(act, action!("complete -s prefix -T auto -D list"));Single
If there is only a single completion candidate, select it.
§Example: Using action!
use editor_types::prelude::*;
use editor_types::{action, Action, EditorAction};
let ct = CompletionType::Auto;
let style = CompletionStyle::Single;
let display = CompletionDisplay::List;
let act: Action = EditorAction::Complete(style, ct, display).into();
assert_eq!(act, action!("complete -s single -T auto -D list"));Trait Implementations§
Source§impl Clone for CompletionStyle
impl Clone for CompletionStyle
Source§fn clone(&self) -> CompletionStyle
fn clone(&self) -> CompletionStyle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more