Autocomplete not filtering

With this code I get a list of options for all keywords but it doesn’t filter them based in input.

const keywords = ['*:', '**:', '#:', '##:', 'backdrop:', 'blank:', 'box:', 'form:', 'filter:', 'image:', 'line:', 'link:', 'paragraph:', 'read:', 'stackName:', 'subtitle:', 'supertitle:', 'tap:', 'title:', 'video:']

export function myCompletions(context: CompletionContext) {
     const startOfLine = context.matchBefore(new RegExp("^.*"));

    if (!startOfLine) return null;

    let options: { label: string; boost?: number }[] = [];
    if (startOfLine) {
        options = => {
            return {
                label: keyword,

    const completion = {
        from: context.pos,
    return completion;

from: context.pos tells the editor that this completes the text between context.pos and context.pos, i.e. the empty string. That’s why there is no filtering. Set a proper from to the start of the node you want to filter on and it should improve.

1 Like