Skip to main content

Module completion

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.
CompletionSource
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.
PreparedSource
A source with its candidates folded once: what the drawer filters per keystroke.
SlowTier
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.
MatchClass
How well a candidate matches the query, best first.
ParamKind
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
next with the row kept (the one the person selected) back at place where 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 query typed after the trigger of source (see the module docs).