editor: Highlight all matching occurrences of text in selection (#24835)
Closes #12635 - [x] Get it working - [x] Disable for multi cursor - [x] Disable for vim visual line selection - [x] Add setting to disable it - [x] Add scrollbar marker - [x] Handle delete state capturing selection Preview: https://github.com/user-attachments/assets/a76cde64-4f6c-4575-91cc-3a03a954e7a9 Release Notes: - Added support to highlight all matching occurrences of text within the selection in editor. --------- Co-authored-by: Agus Zubiaga <agus@zed.dev> Co-authored-by: Danilo <danilo@zed.dev>
This commit is contained in:
parent
1e1b637b50
commit
3e9722685b
5 changed files with 144 additions and 2 deletions
|
@ -20,8 +20,8 @@ use crate::{
|
|||
EditorSettings, EditorSnapshot, EditorStyle, ExpandExcerpts, FocusedBlock, GoToHunk,
|
||||
GutterDimensions, HalfPageDown, HalfPageUp, HandleInput, HoveredCursor, InlineCompletion,
|
||||
JumpData, LineDown, LineUp, OpenExcerpts, PageDown, PageUp, Point, RevertSelectedHunks, RowExt,
|
||||
RowRangeExt, SelectPhase, Selection, SoftWrap, StickyHeaderExcerpt, ToPoint, ToggleFold,
|
||||
ToggleStagedSelectedDiffHunks, CURSORS_VISIBLE_FOR, FILE_HEADER_HEIGHT,
|
||||
RowRangeExt, SelectPhase, SelectedTextHighlight, Selection, SoftWrap, StickyHeaderExcerpt,
|
||||
ToPoint, ToggleFold, ToggleStagedSelectedDiffHunks, CURSORS_VISIBLE_FOR, FILE_HEADER_HEIGHT,
|
||||
GIT_BLAME_MAX_AUTHOR_CHARS_DISPLAYED, MAX_LINE_LEN, MULTI_BUFFER_EXCERPT_HEADER_HEIGHT,
|
||||
};
|
||||
use buffer_diff::{DiffHunkSecondaryStatus, DiffHunkStatus};
|
||||
|
@ -1296,6 +1296,9 @@ impl EditorElement {
|
|||
// Buffer Search Results
|
||||
(is_singleton && scrollbar_settings.search_results && editor.has_background_highlights::<BufferSearchHighlights>())
|
||||
||
|
||||
// Selected Text Occurrences
|
||||
(is_singleton && scrollbar_settings.selected_text && editor.has_background_highlights::<SelectedTextHighlight>())
|
||||
||
|
||||
// Selected Symbol Occurrences
|
||||
(is_singleton && scrollbar_settings.selected_symbol && (editor.has_background_highlights::<DocumentHighlightRead>() || editor.has_background_highlights::<DocumentHighlightWrite>()))
|
||||
||
|
||||
|
@ -5439,11 +5442,14 @@ impl EditorElement {
|
|||
{
|
||||
let is_search_highlights = *background_highlight_id
|
||||
== TypeId::of::<BufferSearchHighlights>();
|
||||
let is_text_highlights = *background_highlight_id
|
||||
== TypeId::of::<SelectedTextHighlight>();
|
||||
let is_symbol_occurrences = *background_highlight_id
|
||||
== TypeId::of::<DocumentHighlightRead>()
|
||||
|| *background_highlight_id
|
||||
== TypeId::of::<DocumentHighlightWrite>();
|
||||
if (is_search_highlights && scrollbar_settings.search_results)
|
||||
|| (is_text_highlights && scrollbar_settings.selected_text)
|
||||
|| (is_symbol_occurrences && scrollbar_settings.selected_symbol)
|
||||
{
|
||||
let mut color = theme.status().info;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue