Skip to main content

Module completion

Module completion 

Source
Expand description

Word collection and prefix matching for autocomplete.

Functions§

char_to_byte
Converts the character index char_index into a byte offset into text, returning the text length when the index is past the end.
collect_words
Collects the unique words of text (length ≥ 3) with their occurrence count, sorted by count descending and then alphabetically.
current_prefix
Returns the run of word characters ending immediately before cursor, where cursor is a character index into text.
current_word
Returns the character-index range of the word containing cursor, scanning both backward and forward from it with is_word_char.
is_word_char
Returns whether character counts as part of a word (alphanumeric or _).
matches
Returns the words starting with prefix and their occurrence count.