yuku / textcomplete

Autocomplete for HTMLTextAreaElement and more.
https://yuku.takahashi.coffee/textcomplete/
MIT License
1.74k stars 303 forks source link

Search result is replaced with `undefined` values #344

Open kbiedrzycki opened 3 years ago

kbiedrzycki commented 3 years ago

Hey!

Wanted to ask about potential bug and possible solution. It occurs when a search result that is being selected from textcomplete suggestions contains $0, $1 or any other number in similar pattern (which I guess represents regex substitution). Basically, what is happening, these substitution patterns are being replaced with empty strings or what is worse, with undefined string, probably because of the lines https://github.com/yuku/textcomplete/blob/main/packages/textcomplete-core/src/SearchResult.ts#L4 and https://github.com/yuku/textcomplete/blob/main/packages/textcomplete-core/src/SearchResult.ts#L24. I wonder what is the use case for that (like, how we can actually provide replacement groups, for example when search result that looks like fun$1() or VALUE$10). We could potentially try to escape these values somehow, but not sure if there's any callback that we can attach to to unescape them once they are parsed. Any suggestions highly appreciated!

TLDR: Selecting a suggestion from a textcomplete that contains regex substitution returns oddly - like ab$5ab -> abundefinedab.

rayzeller commented 2 years ago

bump