Accessing current input in getMatch when displayLabel for completion object specified

Hi,
We have been using the codemirror editor for our use case for almost a year now, and it has been a great experience. I especially like the modular nature of the library which allows adding/updating features!

I have a case in which I would appreciate some help please.

Use case
The use case we support for the editor accepts syntax of type Field Operator Value or Field Operator (Value, Value, ...). I have overridden the completion method using the autocompletion extension as given below.

autocompletion({
        override: [ (ctx) => myCompletions(ctx) ]
});

This works great for suggestions for field and operator.

The problem I am looking to solve
I am extending the current editor syntax to add suggestions for Value, where the values are a predefined set of values - Sunday, Monday, … Saturday. I’d like to show these values in the order of week day and not alphabetically which is the default.

The default option gives the cool filtering with the matched characters underlined and I would like to replicate that.

To override the default behavior I have provided a displayLabel in the Completion object and now would like to use the getMatch method of CompletionResult to match the input.

The syntax of the method is as given below.

getMatch⁠?: fn(completion: Completion, matched⁠?: readonly number[])

How can I access the current input in the editor view in getMatch, I feel like I am missing something but cannot place it. Any help or pointer will be greatly appreciated.

Thank you!
S

You can’t. But you can compare the given matched ranges with the completion’s label.

Okay, and matched will be populated when filter: true, is that right?

Correct. ​​​​​​​