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: usizeWhere 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: usizeIndex into groups of the currently-focused group.
groups.len() means “no focus yet” (just expanded;
next <Tab> focuses index 0).
Implementations§
Source§impl ActiveSnippet
impl ActiveSnippet
Sourcepub fn from_render(rendered: &RenderedSnippet, origin_offset: usize) -> Self
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.
Sourcepub fn has_tabstops(&self) -> bool
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).
Sourcepub fn focus_first(&mut self) -> Option<&TabstopGroup>
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.
Sourcepub fn next(&mut self) -> Option<&TabstopGroup>
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.
Sourcepub fn prev(&mut self) -> Option<&TabstopGroup>
pub fn prev(&mut self) -> Option<&TabstopGroup>
Step backward. Returns None when already at the
first group.
Sourcepub fn current_group(&self) -> Option<&TabstopGroup>
pub fn current_group(&self) -> Option<&TabstopGroup>
Currently-focused group, when one is.
Sourcepub fn current_index(&self) -> Option<u32>
pub fn current_index(&self) -> Option<u32>
Currently-focused group’s index ($N).
Sourcepub fn shift_ranges_after(&mut self, at: usize, delta: isize)
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
impl Clone for ActiveSnippet
Source§fn clone(&self) -> ActiveSnippet
fn clone(&self) -> ActiveSnippet
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more