Expand description
Active-snippet state machine. The host instantiates one
ActiveSnippet when a snippet expands; while it’s the
“active” snippet, <Tab> / <S-Tab> step through
placeholders and edits to one tabstop ripple to the others
that share its index.
Buffer-position tracking is the host’s job. This module owns the intent (which placeholder is focused, what the mirror groups are, exit semantics); the host translates that into rope edits + cursor moves.
Lifecycle:
- Host renders a
RenderedSnippet, splices itstextinto the buffer, and constructs anActiveSnippetkeyed by the snippet’s start position + theRenderedSnippet’s tabstops. - Host moves the cursor to the first tabstop’s range. If it has a default, the host can mark the range selected (vim Visual) so a typed character replaces the default.
<Tab>->ActiveSnippet::nextreturns the next tabstop group; host moves cursor there.- Edit inside one mirror -> host updates the rope, asks
ActiveSnippet::shift_ranges_afterto ripple the change to the other mirrors of the same tabstop group, then re-renders. - Reaching
$0exits; the host drops theActiveSnippetand lets normal Insert-mode resume.
Structs§
- Active
Snippet - State of an in-flight snippet expansion.
- Tabstop
Group - One group of mirror ranges sharing the same tabstop index.
<Tab>cycles between groups; edits within one group ripple to every range in the same group.