-
Notifications
You must be signed in to change notification settings - Fork 6.2k
editor: Highlight all matching occurrences of text in selection #24835
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
Conversation
|
@0xtimsb thanks for working on this. One suggestion: please add markers on the scrollbar on the right not just for where the cursor is at but also where the highlighted text is. The benefit is quickly identifying text anywhere in the editor, not just the area visible in the window. I am not describing anything new, this is how it is done in VSC. Thanks again |
|
Looks great! But yes, please add the scrollbar occurrences view. Massive help when identifying these tokens. Many thanks! |
Co-Authored-By: Smit <smit@zed.dev> Co-Authored-By: Danilo <danilo@zed.dev>
a1c708b to
d3637a3
Compare
SomeoneToIgnore
left a comment
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.
🚀
| let buffer_ranges = | ||
| vec![buffer.anchor_before(0)..buffer.anchor_after(buffer.len())]; | ||
| let query = buffer.text_for_range(selection.range()).collect::<String>(); | ||
| for range in buffer_ranges { |
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.
This is a bit odd: we create a non-mut vec![buffer.anchor_before(0)..buffer.anchor_after(buffer.len())] and then iterate it?
Can unwrap the entire loop it seems.
One potential super nice feature could be expanding a single, empty selection (basically, a caret) to the ends of the word with movement::surrounding_word: then, we can implement highlights like
which we do with tree-sitter.
| } | ||
| let selection = self.selections.newest::<Point>(cx); | ||
| if selection.is_empty() || selection.start.row != selection.end.row { | ||
| self.clear_background_highlights::<SelectedTextHighlight>(cx); |
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.
Technically, we could test all these clear_background_highlights cases.
Closes #12635
Preview:
updated.mp4
Release Notes: