pub struct InsertCompletionState {
pub trigger: CompletionTrigger,
pub anchor: Position,
pub cursor: Position,
pub query: String,
pub raw: Vec<RawCandidate>,
pub rendered: Vec<RenderedCandidate>,
pub selected: usize,
pub user_picked: bool,
pub doc_popup: Option<DocPopupState>,
pub lsp_incomplete: bool,
pub source_filter: Option<SourceId>,
}Expand description
Live state for an in-flight Insert-mode completion. Held by
the host (App.insert_completion: Option<…>) while the
popup is up; dropped on dismiss. Per-source channels and
cancellation tokens live host-side – they pull in tokio
types this crate avoids – so this struct stays
dependency-light enough that any host (TUI today, GPU
later) can reuse it.
Fields§
§trigger: CompletionTrigger§anchor: PositionWhere the replacement region starts. The aggregator’s
query string is buffer[anchor..cursor].
cursor: PositionThe cursor at open-time – carried so the host can
detect cursor moves outside [anchor, cursor] and
dismiss.
query: StringLive filter text. Re-derived by the host on every
keystroke from buffer[anchor..cursor].
raw: Vec<RawCandidate>All raw candidates seen so far. Sync sources push their full output once per query change; async sources push incrementally as their tokio tasks return.
rendered: Vec<RenderedCandidate>Matched + scored + ranked + annotated. Re-derived from
raw whenever query or raw changes.
selected: usizeSelected index into rendered. Sticky across re-rank
when the same candidate is still in the list.
user_picked: bool“Pinned” – the user moved off the default top selection at least once. After pinning, refilter doesn’t reset to index 0; we hold the user’s latest pick instead.
doc_popup: Option<DocPopupState>Documentation popup, when open. None means no popup.
lsp_incomplete: boolWhether the LSP source said isIncomplete: true last
time. The host uses this to decide whether to re-fire
LSP on each keystroke.
source_filter: Option<SourceId>CSM.K2: active filter – narrows rendered to
candidates whose source matches this id. None ⇒
unfiltered (every source contributes). Set by the
per-source filter chords inside completion-popup-mode
(<C-b> / <C-o> / <C-f> / <C-t> / …); cleared by
<C-Space> while the popup is live (or any retrigger).
Implementations§
Source§impl InsertCompletionState
impl InsertCompletionState
Sourcepub fn open(
trigger: CompletionTrigger,
anchor: Position,
cursor: Position,
query: String,
) -> Self
pub fn open( trigger: CompletionTrigger, anchor: Position, cursor: Position, query: String, ) -> Self
Open a fresh popup state at cursor with the given
trigger. anchor is computed by the caller (typically
“scan back to a word boundary”). query starts as the
text between anchor and cursor.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
True if no candidates have been produced yet. The host renders an empty popup with a “loading…” placeholder in this state when an async source is in-flight.
Sourcepub fn selected_candidate(&self) -> Option<&RenderedCandidate>
pub fn selected_candidate(&self) -> Option<&RenderedCandidate>
Currently-selected candidate, if any.
Sourcepub fn select_next(&mut self)
pub fn select_next(&mut self)
Move the selection one step down, wrapping at the end.
Marks user_picked so subsequent refilters don’t snap
back to index 0.
Sourcepub fn select_prev(&mut self)
pub fn select_prev(&mut self)
Move the selection one step up, wrapping at the start.
Trait Implementations§
Source§impl Clone for InsertCompletionState
impl Clone for InsertCompletionState
Source§fn clone(&self) -> InsertCompletionState
fn clone(&self) -> InsertCompletionState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more