Stop highlighting selection matches in the search inputs (#53307)

Kirill Bulatov created

Follow-up of https://github.com/zed-industries/zed/pull/52553

Restores previous search inputs' behavior where no extra highlights were
applied.

Before:


https://github.com/user-attachments/assets/38b6e70c-d5d5-4e06-abec-97d20af44f39

After: 


https://github.com/user-attachments/assets/6e4b3931-adf0-4c2a-afc3-f3c839fc9add


Release Notes:

- N/A

Change summary

crates/editor/src/editor.rs         | 8 +++++++-
crates/search/src/buffer_search.rs  | 1 +
crates/search/src/project_search.rs | 1 +
3 files changed, 9 insertions(+), 1 deletion(-)

Detailed changes

crates/editor/src/editor.rs πŸ”—

@@ -1265,6 +1265,7 @@ pub struct Editor {
     >,
     use_autoclose: bool,
     use_auto_surround: bool,
+    use_selection_highlight: bool,
     auto_replace_emoji_shortcode: bool,
     jsx_tag_auto_close_enabled_in_any_buffer: bool,
     show_git_blame_gutter: bool,
@@ -2468,6 +2469,7 @@ impl Editor {
             read_only: is_minimap,
             use_autoclose: true,
             use_auto_surround: true,
+            use_selection_highlight: true,
             auto_replace_emoji_shortcode: false,
             jsx_tag_auto_close_enabled_in_any_buffer: false,
             leader_id: None,
@@ -3547,6 +3549,10 @@ impl Editor {
         self.use_autoclose = autoclose;
     }
 
+    pub fn set_use_selection_highlight(&mut self, highlight: bool) {
+        self.use_selection_highlight = highlight;
+    }
+
     pub fn set_use_auto_surround(&mut self, auto_surround: bool) {
         self.use_auto_surround = auto_surround;
     }
@@ -7699,7 +7705,7 @@ impl Editor {
         if matches!(self.mode, EditorMode::SingleLine) {
             return None;
         }
-        if !EditorSettings::get_global(cx).selection_highlight {
+        if !self.use_selection_highlight || !EditorSettings::get_global(cx).selection_highlight {
             return None;
         }
         if self.selections.count() != 1 || self.selections.line_mode() {

crates/search/src/buffer_search.rs πŸ”—

@@ -849,6 +849,7 @@ impl BufferSearchBar {
         let query_editor = cx.new(|cx| {
             let mut editor = Editor::auto_height(1, 4, window, cx);
             editor.set_use_autoclose(false);
+            editor.set_use_selection_highlight(false);
             editor
         });
         cx.subscribe_in(&query_editor, window, Self::on_query_editor_event)

crates/search/src/project_search.rs πŸ”—

@@ -939,6 +939,7 @@ impl ProjectSearchView {
             let mut editor = Editor::auto_height(1, 4, window, cx);
             editor.set_placeholder_text("Search all files…", window, cx);
             editor.set_use_autoclose(false);
+            editor.set_use_selection_highlight(false);
             editor.set_text(query_text, window, cx);
             editor
         });