Skip to main content

Module completion

Module completion 

Source
Expand description

Formula autocomplete, window-free: the word being typed before the caret, what may complete it (functions, measures, categories), the ghost text painted after the caret, and the edit that accepting a candidate makes. The formula editors draw the list, the ghost and the signature tooltip from these.

Structs§

Candidate
One completion: the name shown, and what accepting it inserts.
Popup
One editor’s popup: the selected candidate, and whether Esc closed it (it stays closed until the text changes).

Enums§

Kind
What a candidate names.

Constants§

MAX_ITEMS
At most this many candidates are listed.

Functions§

accept
Replace the word at caret (through the end of the identifier the caret is in) with cand: the new text and the caret after it. A function lands as NAME( with the caret after the (, reusing a ( that already follows.
call_hint 🔒
NAME(params) under the name the user typed (an alias keeps its own).
candidates
What may complete word, case-insensitively: the model’s measures, then its categories (each sorted), then the functions, shortest first. A 'quoted word completes model names only.
clamp_variadic 🔒
Argument i of def as an index into its names: a variadic tail repeats, so an index past it lands on the … (or the last name).
ghost
The ghost text after the caret, which must end text. While completing (cand is the selected candidate for the word there) it is the rest of that name, and a function’s (params); else, inside a call, the parameters from the current argument on: after PMT(0.05, it is nper, pv, [fv], [type]), after PMT(0.05 it is , nper, …).
hint_parts
def’s hint split around argument arg: (before, current, after), so the current parameter can be drawn bold. No arg (or one past a fixed parameter list) leaves current empty.
ident_char 🔒
in_string 🔒
Whether byte i of text is inside a "string".
offer
The list to offer while typing at caret: candidates for the word there, at most MAX_ITEMS. Empty once the word is exactly a measure or category name, so Enter after Price * Quantity commits, and when the caret is inside a word or right before a ( (the call is written).
prefix
The word being typed before caret, if it can be completed: not empty, starting with a letter, _ or ', and not in a string.
short_doc
d’s description without a NAME(…) call that spells its parameters (payment per period: PMT(rate, nper, …)), which a hint already shows.
word_start
Byte offset where the word ending at caret starts: the identifier run before it, or an open 'quoted name (spaces and all).