Module completion
Expand description
What a completion drawer offers and in which order: the sources a field completes from
(ui.Completion(trigger: "@", from: …)), and the rows a typed token shows from them.
A field’s view gives each trigger its source once (CompletionSource): the candidates in
priority tiers (this conversation, then the channel, then the workspace), sources that
answer later under their own header (SlowTier), and whether a missing one may be
created. Everything per keystroke happens here, in the UI, against what the source gave:
the token after the trigger is the query, and rows orders the candidates for it.
- No letters yet: each tier under its header, up to its limit.
- While typing: one list without headers. A name or handle starting with the query comes first, then a word in the name starting with it, then the query anywhere in the name or handle, then close fuzzy matches (the query’s letters in order from a word start). Within each, the tiers’ order, then the source’s own. Accents and case fold as system search folds them.
- Slow sources answer below the local rows under their own header, with progress while they are on their way, and never reorder what is shown.
- No match: one row saying so, and “Create …” where the source allows it.
A pick (Pick) is what the field writes in place of the token: the candidate’s inline
text and, where the field keeps rich text, the reference it names.
Structs§
- Candidate
- One thing a completion offers: how it reads in the drawer and what a pick writes.
- Command
- A command a
/source offers: an action, with the parameters its signature asks for. - Completion
Source - What one trigger completes from, as a field’s view gave it.
- Folded
- Text folded as system search folds it, remembering where each folded byte came from.
- Param
- One parameter of a command, as its inline field asks for it.
- Prepared
- A candidate with its name and handle folded once, when its source arrives.
- Prepared
Source - A source with its candidates folded once: what the drawer filters per keystroke.
- Slow
Tier - A source that answers later (people outside the workspace, a directory): its rows come under its own header below the local ones.
- Tier
- One tier of a source: candidates of one priority, under a header shown before anything is typed.
Enums§
- Entry
- One row of the drawer.
- Match
Class - How well a candidate matches the query, best first.
- Param
Kind - What a parameter’s field takes.
- Pick
- What a pick writes in place of the token, or the command it starts.
Constants§
- MAX_
ROWS - The most rows offered for one token, whatever the source holds.
Functions§
- keep_
place nextwith the rowkept(the one the person selected) back atplacewhere it still matches: a still-matching selected row keeps its place while the rest narrow around it. Returns the rows and where the selection is now.- rows
- The drawer’s rows for
querytyped after the trigger ofsource(see the module docs).