-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
match beginning and end of line correctly #3575
base: master
Are you sure you want to change the base?
Conversation
6a8e479
to
c0ba33e
Compare
This "padded regex" approach feels hacky. Maybe it is reliable (I haven't analyzed it carefully yet), but how about a straightforward approach instead: search not just within the given range ( |
That doesn't work because |
Ok, fair point. |
926e411
to
2e3bc77
Compare
I've force-pushed a new version:
I've also rebased the PR so that one can test it together with the changes to the search functionality done in previous PRs. |
Thanks, LGTM (apart from my above comment about comments, and the fact that it's better to squash such fix-up changes into one commit, but we can squash them later). |
Side note: looks like we can deduplicate the code in |
I've combined Moreover, the code at the beginning of One might think of making EDIT: We might also want the first argument to |
When |
8bd0cac
to
3e16d5b
Compare
LGTM, but I've just noticed that it still doesn't fix the issue in the case of So I guess we also need a similar fix in (Unless we treat this as the intended behavior, but then it's inconsistent with |
I was thinking of modifying |
When searching with
buf:FindNext
, the start of the search region currently always matches^
and the end of the region$
, no matter if they are the indeed the start or end of a line. Similar problems exist with other empty-string pattern like\b
. The goal of this PR is to fix this. This is done by modifying the search pattern for the first and last lines (prepending and/or appending.
.Code common to
findDown
andfindUp
has been moved to separate functions. One could tweak the specific way it's done, but maybe it's better to first get some feedback if you are willing to go in this direction at all.