PythonScript icon indicating copy to clipboard operation
PythonScript copied to clipboard

Prevent "research" from generating matches if search string is zero-length

Open sasumner opened this issue 5 years ago • 2 comments

With this code:

matches = []
editor.research('', lambda m: matches.append(m.span(0)))
print(len(matches))

I was semi-surprised to see a non-zero result printed.

Any chance that the plugin could trap on this situation and not match anything? Same for ".search()" and ".replace()" and ".rereplace()" as well, of course.

Obviously I can do that trapping as well, before calling.

sasumner avatar Dec 09 '20 18:12 sasumner

@sasumner With which version of the plugin? python2.7 aka 1.5.4 or a python3 beta release?

chcg avatar Dec 09 '20 18:12 chcg

@chcg

Ach--sorry for omitting that. I'm still using Python 2.7 / 1.5.4

But, I would expect the newer would still work the same way?

Again, I wouldn't call it a "bug", but it might be a nice convenience for the user to trap this. Notepad++ itself doesn't return any matches if Find what is empty and a Find Next is done.

sasumner avatar Dec 09 '20 18:12 sasumner