Regex for keyword hints in simplemode


#1

Hi, I’m trying to use autocomplete on a list of hint words with simple mode, however the regex to match 0 or infinite characters causes the error: Mode simplemode failed to advance stream. If I remove []* from the regex then the error does not occur, but then the hints will only appear when 0 or 1 characters have been typed, whereas I want the hint to appear no matter how many characters have been typed.

The regex I’m using is
{ regex: /[(?:send the|buy the|check the)]*\b/i, token: "keyword" }

Here’s a codepen of the error, which occurs if you try to type Buy the second, having used autocomplete for Buy the.

Thanks.


#2

Modes don’t really produce hints, so I’m not sure how hints come into this. But yes, if your mode keeps on matching nothing and calling it a token, that’d be an infinite loop, and the editor will abort it.