How do you filter completions?

I created codemirror-languageservice, a library to integrate LSP compatible language services into CodeMirror. I made a live demo on CodeMirror language service JSON example that integrates vscode-json-languageservice. I’m having some problems implementing filtering. For example, in the license field of the live demo, type m. I would expect only licenses to show up that contain the letter m.

The autocompletion documentation describes that it should be possible. It kind of looks like it should even work automagically. Its demo also shows completion filtering, but there’s no reference to the source code.

How do I implement filtering of completions?

Yes, filtering is automatic unless you turn it off explicitly with filter: false. Make sure your completion result (from/to) covers the range of the construct you are completing, though.

Thanks! It now works by setting the from and to fields based on LSP results. (pull request) (preview)

However, now when a completion is applied, it’s no longer possible to trigger further completions. Do you have any idea what could cause that?

Apparently I made the assumption to should be greater than from, but it may be equal as well.

I got it working as expected now. The only behaviour that’s unexpected now is that if I autocomplete the following, where | represents the cursor position:

{
  "license": "|"
}

The completions include all license information, but in quotes with information to replace the empty string with a quoted license information. As a result all completions are filtered. I’m not sure why vscode-json-languageservice gives back these results, not why CodeMirror filters this.