Remove the stale code

Kirill Bulatov created

Change summary

crates/multi_buffer/src/multi_buffer.rs |  2 
crates/search/Cargo.toml                |  1 
crates/search/src/project_search.rs     | 61 ++++++--------------------
3 files changed, 15 insertions(+), 49 deletions(-)

Detailed changes

crates/multi_buffer/src/multi_buffer.rs 🔗

@@ -1762,7 +1762,7 @@ impl MultiBuffer {
     }
 
     #[instrument(skip_all)]
-    pub fn merge_excerpt_ranges<'a>(
+    fn merge_excerpt_ranges<'a>(
         expanded_ranges: impl IntoIterator<Item = &'a ExcerptRange<Point>> + 'a,
     ) -> Vec<ExcerptRange<Point>> {
         let mut sorted: Vec<_> = expanded_ranges.into_iter().collect();

crates/search/Cargo.toml 🔗

@@ -53,7 +53,6 @@ editor = { workspace = true, features = ["test-support"] }
 gpui = { workspace = true, features = ["test-support"] }
 language = { workspace = true, features = ["test-support"] }
 lsp.workspace = true
-multi_buffer.workspace = true
 pretty_assertions.workspace = true
 unindent.workspace = true
 workspace = { workspace = true, features = ["test-support"] }

crates/search/src/project_search.rs 🔗

@@ -9,7 +9,7 @@ use crate::{
     },
 };
 use anyhow::Context as _;
-use collections::{HashMap, HashSet};
+use collections::HashMap;
 use editor::{
     Anchor, Editor, EditorEvent, EditorSettings, MAX_TAB_TITLE_LEN, MultiBuffer, PathKey,
     SelectionEffects,
@@ -333,6 +333,7 @@ impl ProjectSearch {
             }
         })
     }
+
     fn subscribe_to_excerpts(
         excerpts: &Entity<MultiBuffer>,
         cx: &mut Context<Self>,
@@ -433,7 +434,6 @@ impl ProjectSearch {
             }
 
             let mut limit_reached = false;
-            let mut seen_paths = HashSet::default();
             while let Some(results) = matches.next().await {
                 let (buffers_with_ranges, has_reached_limit) = cx
                     .background_executor()
@@ -456,14 +456,14 @@ impl ProjectSearch {
                 limit_reached |= has_reached_limit;
 
                 if incremental {
-                    let buffers_with_ranges: Vec<_> = buffers_with_ranges
+                    let buffers_with_ranges = buffers_with_ranges
                         .into_iter()
                         .filter(|(_, ranges)| !ranges.is_empty())
-                        .collect();
+                        .collect::<Vec<_>>();
                     if buffers_with_ranges.is_empty() {
                         continue;
                     }
-                    let (mut chunk_ranges, chunk_paths) = project_search
+                    let (mut chunk_ranges, _) = project_search
                         .update(cx, |project_search, cx| {
                             let mut paths = Vec::new();
                             let futures = project_search.excerpts.update(cx, |excerpts, cx| {
@@ -485,7 +485,6 @@ impl ProjectSearch {
                             (futures, paths)
                         })
                         .ok()?;
-                    seen_paths.extend(chunk_paths);
                     while let Some(ranges) = chunk_ranges.next().await {
                         smol::future::yield_now().await;
                         project_search
@@ -529,44 +528,14 @@ impl ProjectSearch {
                 }
             }
 
-            if incremental {
-                project_search
-                    .update(cx, |project_search, cx| {
-                        if seen_paths.is_empty() {
-                            project_search
-                                .excerpts
-                                .update(cx, |excerpts, cx| excerpts.clear(cx));
-                        } else {
-                            // TODO kb
-                            // project_search.excerpts.update(cx, |excerpts, cx| {
-                            //     let stale = excerpts
-                            //         .paths()
-                            //         .filter(|path| !seen_paths.contains(*path))
-                            //         .cloned()
-                            //         .collect::<Vec<_>>();
-                            //     for path in stale {
-                            //         excerpts.remove_excerpts_for_path(path, cx);
-                            //     }
-                            // });
-                        }
-                        project_search.no_results = Some(project_search.match_ranges.is_empty());
-                        project_search.limit_reached = limit_reached;
-                        project_search.pending_search.take();
-                        cx.notify();
-                    })
-                    .ok()?;
-            } else {
-                project_search
-                    .update(cx, |project_search, cx| {
-                        if !project_search.match_ranges.is_empty() {
-                            project_search.no_results = Some(false);
-                        }
-                        project_search.limit_reached = limit_reached;
-                        project_search.pending_search.take();
-                        cx.notify();
-                    })
-                    .ok()?;
-            }
+            project_search
+                .update(cx, |project_search, cx| {
+                    project_search.no_results = Some(project_search.match_ranges.is_empty());
+                    project_search.limit_reached = limit_reached;
+                    project_search.pending_search.take();
+                    cx.notify();
+                })
+                .ok()?;
 
             None
         }));
@@ -1037,8 +1006,7 @@ impl ProjectSearchView {
                         }
                     }
 
-                    let search_settings = &EditorSettings::get_global(cx).search;
-                    if search_settings.search_on_input {
+                    if EditorSettings::get_global(cx).search.search_on_input {
                         if this.query_editor.read(cx).is_empty(cx) {
                             this.entity.update(cx, |model, cx| {
                                 model.pending_search = None;
@@ -1692,7 +1660,6 @@ impl ProjectSearchView {
         let editor = match kind {
             SearchInputKind::Query => &self.query_editor,
             SearchInputKind::Include => &self.included_files_editor,
-
             SearchInputKind::Exclude => &self.excluded_files_editor,
         };
         editor.update(cx, |editor, cx| {