Skip to main content

InsertCompletionState

Struct InsertCompletionState 

Source
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: Position

Where the replacement region starts. The aggregator’s query string is buffer[anchor..cursor].

§cursor: Position

The cursor at open-time – carried so the host can detect cursor moves outside [anchor, cursor] and dismiss.

§query: String

Live 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: usize

Selected 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: bool

Whether 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

Source

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.

Source

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.

Source

pub fn selected_candidate(&self) -> Option<&RenderedCandidate>

Currently-selected candidate, if any.

Source

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.

Source

pub fn select_prev(&mut self)

Move the selection one step up, wrapping at the start.

Trait Implementations§

Source§

impl Clone for InsertCompletionState

Source§

fn clone(&self) -> InsertCompletionState

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for InsertCompletionState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more