radian-software/ctrlf

Search by distance from the beginning position

irigone opened this issue · 2 comments

Sometimes I don't know if the place I need is above or below the current position. In such cases, I would run consult-line (it's swiper for Selectrum). By default, it shows all lines on the screen, you can choose between them with C-n and C-p, the nearest line is the first candidate, the furthest line is the last candidate. However, sometimes consult-line isn't usable, because it shows a single line, which provides less context than showing the whole screen.
I want ctrlf to sort the candidates by distance from the beginning position, e.g. sort all candidates by the distance and move to the first in the sorted list, then when C-s is typed to the second one, then to the third one... If this was implemented, I would stop using consult-line at all.

While I'm not immediately opposed to the concept, it would be a significant implementation challenge. The reason for this is that currently CTRLF can operate by jumping incrementally from one match to the next, rather than needing to scan the entire buffer for matches before deciding what to do. For a command like consult-line, the behavior of scanning the entire buffer for matches, and then doing something with the list of results, makes much more sense to me. If we were to implement a similar thing in CTRLF, I would worry about the performance implications. We would have to have a "fast mode" and a "slow mode", and that seems like it could lead to a lot of unwanted complexity.

Ok then :(