-
-
Notifications
You must be signed in to change notification settings - Fork 337
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
Fix insert action for swiper-isearch #2963
Fix insert action for swiper-isearch #2963
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This continues cleaning up the sad state of regressions between swiper
and swiper-isearch
that I also tried improving in #2913 and #2914.
This change assumes numbers passed to
ivy--action-insert
are valid buffer positions in the current buffer, and converts them to a string containing the line that buffer position is on, allowinginsert
to do the right thing.
Ivy is meant to be a low-level generic completion framework, and Swiper simply a client thereof. I think it's therefore better if Ivy remain as unaware of Swiper implementation details as possible, and this issue be fixed on the Swiper side instead.
That calls for a swiper-isearch
override of the i
(insert) action. Have a look at #2914 to see how I did this for the o
(default) and w
(copy) actions; you may be able to reuse some of the functions there. Thanks.
Looking at the implementation of swiper-isearch-action-copy, it looks like it only copies the portion of the line that is the exact match of your So it would make sense for an insert action to do the same, but that's not really the feature I was trying to fix/implement. My use case is that after finding a line via So I guess this is just an idiosyncrasy of my workflow, and I should just add my own custom action to |
adc9a65
to
a5f3bc0
Compare
@basil-conto , thanks for the feedback! Here's a new attempt mirroring your copy action, staying consistent with only inserting the match-string instead of the entire line which my first attempt did. |
How's this look to get checked in? Would be nice to have this functionality! |
I assume my problem (#3006) depends on the problem that RP try to fix. Would be great if this could be merged. |
* swiper.el (swiper-isearch-action-insert): New function modeled after swiper-isearch-action-copy (abo-abo#2913, abo-abo#2914). (swiper-isearch): Override the default 'insert' action with it. Fixes abo-abo#2929. Copyright-paperwork-exempt: yes
a5f3bc0
to
72977e2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
This takes into account swiper-goto-start-of-match and swiper-isearch-backward, under which point precedes and does not follow the candidate (#2913, #2914, #2929, #2963). * swiper.el (swiper--isearch-candidate-string): New helper function. (swiper-isearch-action-copy, swiper-isearch-action-insert): Use it.
Sorry for the delay in merging this. Please have a look at my followup change for supporting |
swiper-isearch
passes a buffer position toivy--action-insert
. The existing insert action throws an error. #2929This change assumes numbers passed to
ivy--action-insert
are valid buffer positions in the current buffer, and converts them to a string containing the line that buffer position is on, allowinginsert
to do the right thing.