Unexpected autocomplete behaviour with hyphens

Using the autocomplete extension, I am seeing that for words that contain a hyphen -, the autocomplete ignores any character that goes before the hyphen.

Autocompleting a word with a hyphen

turns into:

So it’s ignoring the “e-” characters, and appending the rest of the autocomplete in front.

This is using a custom lezer grammar, but the node shown is one that does not contain any nested nodes. Rather this seems to happen with any node containing hyphens.

I am wondering if this is a configuration that I am missing, something intended, or a bug of the autocomplete extension.

Thank you!

This problem looks like it is in your custom autocompletion source (it’s probably not setting the correct from on its return value).

1 Like

You are completely right :slight_smile: My autocomplete logic was matching the words using:
let word = context.matchBefore(/\w*/) satisfies Word
Updating the regex to /\w+[-]?\w*/ fixed the issue.

Thank you!!