New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
editor.research() and editor.search() won't search backwards #323
Comments
And in case there's confusion as to why it matters whether a search is done forward or backward: it's the same reason that saved When I developed this script, I had to resort to doing a loop of 1-match calls to |
Well, I didn't think we'd have to justify a backward search ... :-) My use case is that I'm searching for a specific string/regex either forward or backward from the current caret position. |
Workaround: Insert the following code right after if pos1 > pos2: # workaround!
__ = editor.findText(FINDOPTION.REGEXP, pos1, pos2, 'a')
if __ is not None:
(pos1, pos2) = __
# pos1 will now be LESS than pos1 so editor.research() will succeed |
Under PS 3.0.16.0 (and 2.0.0.0 as well),
editor.research()
andeditor.search()
won't search backwards, i.e., when thestartPosition
argument is greater than theendPosition
argument. It return no matches in such a case.Here is a script which demonstrates the problem, when the script is executed to act upon its own code as input data in the active editor tab in N++:
To see the problem, run the script as written. To see that the script logic works for a forward search, comment out the "swap" line. Note that a call to
editor.findText()
is included to show that it works correctly for either backward or forward searches.The text was updated successfully, but these errors were encountered: