Skip to content

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

Closed

Description

@sasumner

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.

Activity

  1. chcg commented on Dec 9, 2020

    @chcg
    Collaborator

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

  2. sasumner commented on Dec 9, 2020

    @sasumner
    Author

    @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.

  3. Ekopalypse commented on Dec 31, 2024

    @Ekopalypse
    Contributor

    @chcg - Can this be labelled Enhancement or can it be closed?

  4. alankilborn commented on Dec 31, 2024

    @alankilborn

    I don't think it should be closed.
    It seems to find a match at every position in a document.
    This seems, well, unexpected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions