kmarius / jsregexp

JavaScript regular expressions for Lua
MIT License
29 stars 3 forks source link

skip one character on empty match. #2

Closed L3MON4D3 closed 2 years ago

L3MON4D3 commented 2 years ago

Hi, I'm still working on the lsp-parser for luasnip and noticed that global is a bit broken right now (empty matches are not accepted at all). I've modeled my solution to this after quickjs (see here, where, if I'm understanding everything correctly, the character after the empty match is skipped, to prevent matching it again.) This works, a downside is that matches sometimes have an empty match appended (eg. s/(.*)/g on a -> {[1,2], [2,2]}), but this seems to be consistent with some quick testing I did via https://rcode5.github.io/jsregex/ and vscode itself

https://user-images.githubusercontent.com/41961280/178162489-fa0b9a31-77d0-4e8c-9a33-2848c9d30a6a.mp4

(you can see the a from the second match at the end)

What do you think? It's certainly not pretty, and will have to be adapted a bit for unicode, but it works.

kmarius commented 2 years ago

Thanks, merged.

L3MON4D3 commented 2 years ago

Nice, thank you👍

L3MON4D3 commented 2 years ago

Oh, could you make a new release with this patch?

kmarius commented 2 years ago

Oh, could you make a new release with this patch?

Done.

L3MON4D3 commented 2 years ago

Ty! 👍👍