BagSync

BagSync

3M Downloads

Lua pattern matching in search intentional?

tflo opened this issue · 3 comments

commented

Searching for the "De-Weaponized Mechanical Companion" pet with de-weap as search string didn't return any hits. I remembered that the hyphen has a non-literal meaning in Lua's string.find and, to my surprise, by escaping it de%-weap the search worked as expected.

I say "to my surprise" because I haven't seen it mentioned anywhere that we can use Lua patterns, also not in the Search Help (but often I'm blind, lol).

When I turn off pattern matching in line 86, LibItemScout-1.0.lua …

text:lower():find(search, 1, true)

…then it works "as expected". (Though I haven't checked if it has any side-effects…)

So I'm not sure if you accidentally left the pattern search on, or if you just forgot to document it for the user.

Personally, I find it good when I can use patterns. So, for example, if I don't know if it's spelled with a hypen or not, I can search for de%-*weap or simply de.*weap

However, the Lua pattern syntax is quite different from the more common Perl-ish regexes, so I don't know if many people will use it without some documentation.

Also, many other addons that provide a search (Stash, Armory, TSM, Global Search) do not recognize patterns (at least not Lua patterns), so the user (me included) may be used to that behavior and be surprised if a character is interpreted as a special character.

Maybe add an option somewhere in the config?

commented

Whoops! Yep that's a bug. I forgot to turn off pattern matching lol. I normally turn it off as honestly VERY little people actually ever use pattern matching and it causes more headaches then benefits. I'll just turn it off and if you ever want to turn it on, just edit the file manually. Thanks for pointing this out! This was a great find.

commented

I'll just turn it off and if you ever want to turn it on, just edit the file manually.

Damn, I shouldn't have told you… 😉

No, seriously, I also think that the cases where it can really be useful are few. (Otherwise I already would have suggested to add pattern search, lol 🙃)

commented

hahaha TOOOOO LATE. I already fixed it.

evil laugh

Thanks though for putting in the ticket, that was awesome of you.