Allow call to swiper with initial-input to find the next closest value after point. #2930
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When function swiper is called with an initial-input and the current point is on a line that does not contain a match, the current code returns nil for preselect, which then causes the first viable candidate to be used, which is the first candidate in the buffer.
This small change selects the first candidate following the current point, which allows for a simple repeat-search function to wrap a call to swiper.
##Background
I have a utility function to perform a repeat search after an initial search. The function is very simple
The default behavior of this changed, some time ago (issue #2157 commit 50ead7e). This commit changed the preselect to return the candidate on the current line or to nil, which will cause the first candidate in the entire buffer to be chosen.
As can be in the change, if we modify this from equal to less than, it takes the first candidate with a line number greater than the current point. If this fails (nil) then it will choose the first candidate in the buffer.