# Post processing fuzzily matched autocomplete options

**URL:** <https://discuss.codemirror.net/t/post-processing-fuzzily-matched-autocomplete-options/9709>\
**Category:** v6\
**Created:** [April 6, 2026, 6:18pm UTC](https://discuss.codemirror.net/t/post-processing-fuzzily-matched-autocomplete-options/9709 "2026-04-06T18:18:13Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![push-f](https://discuss.codemirror.net/letter_avatar_proxy/v4/letter/p/ce73a5/32.png) [@push-f](https://discuss.codemirror.net/u/push-f)\
**Post date:** [April 6, 2026, 6:18pm UTC](https://discuss.codemirror.net/t/post-processing-fuzzily-matched-autocomplete-options/9709/1 "2026-04-06T18:18:13Z")

</div>

I’m happy with the fuzzy matching that `@codemirror/autocomplete` implements internally. After the fuzzy matching has sorted and filtered out options, I’d like to append a _load more_ option at the very end to on-demand load more options. I figured out that in [`Completion.apply`](https://codemirror.net/docs/ref/#autocomplete.Completion.apply) I can trigger the list of options to be updated once they have been fetched with [`startCompletion`](https://codemirror.net/docs/ref/#autocomplete.startCompletion). My issue now is that I’d like to avoid re-implementing the fuzzy matching logic the library already has but the library also not exposing it nor providing a hook to customize the options post fuzzy matching.

Happy Easter!

Edit: I realized I have another sort criteria: I’d like to put exact `apply` text matches first.

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/marijn/32/136_2.png) [@marijn](https://discuss.codemirror.net/u/marijn)\
**Post date:** [April 7, 2026, 3:01pm UTC](https://discuss.codemirror.net/t/post-processing-fuzzily-matched-autocomplete-options/9709/2 "2026-04-07T15:01:35Z")

</div>

I don’t think this is something that is possible with @codemirror/autocomplete. How are you updating the list of options? That already doesn’t sound like a thing the package supports.

---

<div class="post-metadata">

**Author:** ![push-f](https://discuss.codemirror.net/letter_avatar_proxy/v4/letter/p/ce73a5/32.png) [@push-f](https://discuss.codemirror.net/u/push-f)\
**Post date:** [April 7, 2026, 3:22pm UTC](https://discuss.codemirror.net/t/post-processing-fuzzily-matched-autocomplete-options/9709/3 "2026-04-07T15:22:27Z")

</div>

Triggering `startCompletion` while the options are already open apparently causes the completion source to be run again, so I’d use that. The state is outside the editor and just accessed in the completion source, which is fine for my use case.

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/marijn/32/136_2.png) [@marijn](https://discuss.codemirror.net/u/marijn)\
**Post date:** [April 7, 2026, 3:55pm UTC](https://discuss.codemirror.net/t/post-processing-fuzzily-matched-autocomplete-options/9709/4 "2026-04-07T15:55:34Z")

</div>

> [@push-f](#):
>
> Triggering `startCompletion` while the options are already open apparently causes the completion source to be run again, so I’d use that.

Wouldn’t that also apply the filtering then?

---

<div class="post-metadata">

**Author:** ![push-f](https://discuss.codemirror.net/letter_avatar_proxy/v4/letter/p/ce73a5/32.png) [@push-f](https://discuss.codemirror.net/u/push-f)\
**Post date:** [April 8, 2026, 3:53pm UTC](https://discuss.codemirror.net/t/post-processing-fuzzily-matched-autocomplete-options/9709/5 "2026-04-08T15:53:25Z")

</div>

Yes, that’s what I want. I’m starting with 200 common options that are bundled into the app and will satisfy most users. Few users may want to select a different option (among 8k total). I don’t want to bundle all of them in the app so I’m chunking them based on their first letter. When you select _load more_ it would expand the options to be filtered to the additional options for the current input.

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/marijn/32/136_2.png) [@marijn](https://discuss.codemirror.net/u/marijn)\
**Post date:** [April 10, 2026, 7:16pm UTC](https://discuss.codemirror.net/t/post-processing-fuzzily-matched-autocomplete-options/9709/6 "2026-04-10T19:16:25Z")

</div>

Right, but what is not working then? Re-running completion with your source rigged to produce more options will put the options into the regular completion flow, and cause them to be filtered and ranked as normal.

---

<div class="post-metadata">

**Author:** ![push-f](https://discuss.codemirror.net/letter_avatar_proxy/v4/letter/p/ce73a5/32.png) [@push-f](https://discuss.codemirror.net/u/push-f)\
**Post date:** [April 10, 2026, 7:33pm UTC](https://discuss.codemirror.net/t/post-processing-fuzzily-matched-autocomplete-options/9709/7 "2026-04-10T19:33:22Z")

</div>

The `load more` option itself gets filtered out because it doesn’t match the text. I want to display it irrespective of the filtering that applies to the other options.

And then I’d also like to fine-tune the fuzzy sorting so that exact `apply` text matches are first (my options are labeled `${description} (${applyText})` so searching for the apply text does match but I’d like to prioritize exact apply text matches over exact description matches.

Both of this would be easily possible if I could modify the options post filtering and sorting (which could be done either by providing a hook and keeping the fuzzy matcher an implementation detail or by exposing it so that I could use it with `filter: false`).

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/marijn/32/136_2.png) [@marijn](https://discuss.codemirror.net/u/marijn)\
**Post date:** [April 11, 2026, 5:47pm UTC](https://discuss.codemirror.net/t/post-processing-fuzzily-matched-autocomplete-options/9709/8 "2026-04-11T17:47:35Z")

</div>

Yeah, that sounds like it is outside of what this package supports.

---

<div class="post-metadata">

**Author:** ![push-f](https://discuss.codemirror.net/letter_avatar_proxy/v4/letter/p/ce73a5/32.png) [@push-f](https://discuss.codemirror.net/u/push-f)\
**Post date:** [April 11, 2026, 6:00pm UTC](https://discuss.codemirror.net/t/post-processing-fuzzily-matched-autocomplete-options/9709/9 "2026-04-11T18:00:03Z")

</div>

Right. I could see if I find a nice way to extend it to support this? Or do you think this is out of scope?

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/marijn/32/136_2.png) [@marijn](https://discuss.codemirror.net/u/marijn)\
**Post date:** [April 12, 2026, 12:26pm UTC](https://discuss.codemirror.net/t/post-processing-fuzzily-matched-autocomplete-options/9709/10 "2026-04-12T12:26:21Z")

</div>

You may be able to pass in your always-present thing via a separate completion source, with `filter: false` to make sure it shows up . Fine-tuning the completion matching is out of scope for this package.
