Skip to content
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

Highlight matches of consult-lines in buffer #253

Closed
failable opened this issue Mar 13, 2021 · 6 comments
Closed

Highlight matches of consult-lines in buffer #253

failable opened this issue Mar 13, 2021 · 6 comments

Comments

@failable
Copy link

Currently the matches of consult-lines are not highlighted in the original buffer. Sometimes it's a bit hard to locate the matches, i.e. when the matched line is long. Besides, when using commands like consult-lines or swiper, I personally focus on the buffer lines rather than the minibuffer because the lines around the matches provide more context than the individual match lines as shown in the minibuffer.

Is it possible to have highlights in the buffer line? Thanks.

consult-lines
Screen Shot 2021-03-13 at 10 46 30 PM

swiper
Screen Shot 2021-03-13 at 10 46 50 PM

isearch-forward
Screen Shot 2021-03-13 at 10 46 59 PM

@minad
Copy link
Owner

minad commented Mar 13, 2021

Yes, this is a known issue. I personally don't need this feature, since I am happy with the minibuffer view in combination with preview when scrolling through the matches. Only very few matches may be visible in the buffer, many more will lie outside the visible region. Furthermore there are faster solutions if you want to jump to matches within the visible region, e.g. isearch, avy etc. The strength of swiper/consult-line is the overview.

The problem has been that the implementation of this feature is a bit intricate since we are using the completion styles to perform the filtering. This means we also have to rely on the completion style to obtain the highlighting. There is 1. either the possibility to use the filtered strings (propertized by the completion style) and use them as overlays or 2. somehow extract the positions of the matches by looking for the completion style faces. Option 2 is problematic since the completion styles can define their own faces such that there is no consistency one could rely on.

If someone proposes a patch I would be happy to merge it.

@minad
Copy link
Owner

minad commented Mar 13, 2021

See also previous issues #7 and #26.

@Inc0n
Copy link

Inc0n commented Mar 28, 2021

I would like to suggest an alternative in solving this issue (which in return would solve mine ...)

I have written a couple utility ripgrep and swipe-like function with selectrum, and I have configured so they would add the search pattern after the completion to the evil-search that I use, then I would be able to quickly navigate between matches.

I think this way OP can, assumably that isearch would provide a good navigation interface (I do not use isearch, but instead the evil-mode search, so again it's an assumption made here), navigate the matches quickly.

@minad
Copy link
Owner

minad commented May 7, 2021

The situation regarding highlighting improved a bit with #281, since we only highlight the current visual line with the match. But there is still no solution for highlighting the matches of all lines in sight. Closing for now due to interactivity and since there is no intention to implement this. If someone comes forward with a good idea on how to implement the feature (or even better a patch!) we can reconsider.

@minad minad closed this as completed May 7, 2021
@muirdm
Copy link

muirdm commented Mar 24, 2023

Perhaps this could be implemented generally by supporting previewing multiple candidates? The read would specify a function that returns the subset of candidates to preview. For consult-line, the function would yield visible candidates. May not be applicable to many reads other than those that deal with lines in file(s).

@minad
Copy link
Owner

minad commented Mar 24, 2023

Perhaps this could be implemented generally by supporting previewing multiple candidates? The read would specify a function that returns the subset of candidates to preview.

This is a generalization which is too difficult and goes too far. The alternative would be to special case the multi preview only for consult-line. Personally I am happy with the status quo, but of course feel free to experiment.

muirdm added a commit to muirdm/consult that referenced this issue Mar 25, 2023
Tweak the list of line matches to optionally also include other lines'
matches.

I didn't enable by default because it is noticeably slower in
large buffers.

It's tricky to avoid O(n^2) pitfalls due to the contortions required
to detect and propagate the matches.

Updates minad#253
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants