Skip to main content

ActiveSnippet

Struct ActiveSnippet 

Source
pub struct ActiveSnippet {
    pub origin_offset: usize,
    pub groups: Vec<TabstopGroup>,
    pub current: usize,
}
Expand description

State of an in-flight snippet expansion.

Fields§

§origin_offset: usize

Where in the buffer this snippet began. The host uses this as the reference origin for offset arithmetic on the tabstop ranges.

§groups: Vec<TabstopGroup>

Tabstop groups in display order ($1, $2, …, $0 last when present). Cycle order matches the LSP / TextMate convention: 1, 2, 3, …, then 0 to exit.

§current: usize

Index into groups of the currently-focused group. groups.len() means “no focus yet” (just expanded; next <Tab> focuses index 0).

Implementations§

Source§

impl ActiveSnippet

Source

pub fn from_render(rendered: &RenderedSnippet, origin_offset: usize) -> Self

Build from a freshly-rendered snippet placed at the given byte offset in the buffer. Groups are built in $1 -> $2 -> ... -> $0 order so navigation matches the LSP convention.

Source

pub fn has_tabstops(&self) -> bool

True when the snippet has at least one tabstop group to navigate. False when the body was pure literal text (in which case the host doesn’t need an ActiveSnippet at all).

Source

pub fn focus_first(&mut self) -> Option<&TabstopGroup>

Focus the first tabstop group. Called by the host right after inserting the rendered text. Returns the group, or None when the snippet has no tabstops.

Source

pub fn next(&mut self) -> Option<&TabstopGroup>

Step to the next tabstop group. Returns None when the snippet has been exited ($0 consumed or no further groups). The host drops the ActiveSnippet when this returns None.

Source

pub fn prev(&mut self) -> Option<&TabstopGroup>

Step backward. Returns None when already at the first group.

Source

pub fn current_group(&self) -> Option<&TabstopGroup>

Currently-focused group, when one is.

Source

pub fn current_index(&self) -> Option<u32>

Currently-focused group’s index ($N).

Source

pub fn shift_ranges_after(&mut self, at: usize, delta: isize)

Shift downstream ranges after a buffer edit at byte offset at. The host calls this AFTER manually expanding the active tabstop’s range to include the edit; this method only handles ranges strictly past the edit point. delta is signed: positive on insert, negative on delete.

The split (host expands active tabstop, this expands downstream) keeps the contract small. Snippet engines that ripple mirror edits typically own the per-mirror expansion logic; v1 does that host-side too. A future ripple_edit helper can encapsulate both halves once the host’s edit-pipeline integration lands.

Trait Implementations§

Source§

impl Clone for ActiveSnippet

Source§

fn clone(&self) -> ActiveSnippet

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 ActiveSnippet

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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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