From 1433160a08fcfa843a05f27164ef0deec578e6da Mon Sep 17 00:00:00 2001 From: KCaverly Date: Fri, 15 Sep 2023 15:16:20 -0400 Subject: [PATCH] enable include based filtering for search inside open and modified buffers --- crates/semantic_index/src/semantic_index.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/crates/semantic_index/src/semantic_index.rs b/crates/semantic_index/src/semantic_index.rs index 06c7aa53fa00bc051ca51ab7b72de4b7729b02ff..f9ac6a0ae19474258c2e56c9352329fc261ec234 100644 --- a/crates/semantic_index/src/semantic_index.rs +++ b/crates/semantic_index/src/semantic_index.rs @@ -714,7 +714,14 @@ impl SemanticIndex { let search_start = Instant::now(); let modified_buffer_results = this.update(&mut cx, |this, cx| { - this.search_modified_buffers(&project, query.clone(), limit, &excludes, cx) + this.search_modified_buffers( + &project, + query.clone(), + limit, + &includes, + &excludes, + cx, + ) }); let file_results = this.update(&mut cx, |this, cx| { this.search_files(project, query, limit, includes, excludes, cx) @@ -877,6 +884,7 @@ impl SemanticIndex { project: &ModelHandle, query: Embedding, limit: usize, + includes: &[PathMatcher], excludes: &[PathMatcher], cx: &mut ModelContext, ) -> Task>> { @@ -890,7 +898,16 @@ impl SemanticIndex { let excluded = snapshot.resolve_file_path(cx, false).map_or(false, |path| { excludes.iter().any(|matcher| matcher.is_match(&path)) }); - if buffer.is_dirty() && !excluded { + + let included = if includes.len() == 0 { + true + } else { + snapshot.resolve_file_path(cx, false).map_or(false, |path| { + includes.iter().any(|matcher| matcher.is_match(&path)) + }) + }; + + if buffer.is_dirty() && !excluded && included { Some((buffer_handle, snapshot)) } else { None