catchup with main
This commit is contained in:
commit
300c693d55
34 changed files with 1443 additions and 415 deletions
|
@ -1,7 +1,6 @@
|
|||
use crate::{parsing::Document, SEMANTIC_INDEX_VERSION};
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use globset::GlobMatcher;
|
||||
use project::Fs;
|
||||
use project::{search::PathMatcher, Fs};
|
||||
use rpc::proto::Timestamp;
|
||||
use rusqlite::{
|
||||
params,
|
||||
|
@ -290,8 +289,8 @@ impl VectorDatabase {
|
|||
pub fn retrieve_included_file_ids(
|
||||
&self,
|
||||
worktree_ids: &[i64],
|
||||
include_globs: Vec<GlobMatcher>,
|
||||
exclude_globs: Vec<GlobMatcher>,
|
||||
includes: &[PathMatcher],
|
||||
excludes: &[PathMatcher],
|
||||
) -> Result<Vec<i64>> {
|
||||
let mut file_query = self.db.prepare(
|
||||
"
|
||||
|
@ -310,13 +309,9 @@ impl VectorDatabase {
|
|||
while let Some(row) = rows.next()? {
|
||||
let file_id = row.get(0)?;
|
||||
let relative_path = row.get_ref(1)?.as_str()?;
|
||||
let included = include_globs.is_empty()
|
||||
|| include_globs
|
||||
.iter()
|
||||
.any(|glob| glob.is_match(relative_path));
|
||||
let excluded = exclude_globs
|
||||
.iter()
|
||||
.any(|glob| glob.is_match(relative_path));
|
||||
let included =
|
||||
includes.is_empty() || includes.iter().any(|glob| glob.is_match(relative_path));
|
||||
let excluded = excludes.iter().any(|glob| glob.is_match(relative_path));
|
||||
if included && !excluded {
|
||||
file_ids.push(file_id);
|
||||
}
|
||||
|
|
|
@ -11,13 +11,12 @@ use anyhow::{anyhow, Result};
|
|||
use db::VectorDatabase;
|
||||
use embedding::{EmbeddingProvider, OpenAIEmbeddings};
|
||||
use futures::{channel::oneshot, Future};
|
||||
use globset::GlobMatcher;
|
||||
use gpui::{AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, Task, WeakModelHandle};
|
||||
use language::{Anchor, Buffer, Language, LanguageRegistry};
|
||||
use parking_lot::Mutex;
|
||||
use parsing::{CodeContextRetriever, Document, PARSEABLE_ENTIRE_FILE_TYPES};
|
||||
use postage::watch;
|
||||
use project::{Fs, Project, WorktreeId};
|
||||
use project::{search::PathMatcher, Fs, Project, WorktreeId};
|
||||
use smol::channel;
|
||||
use std::{
|
||||
cmp::Ordering,
|
||||
|
@ -683,8 +682,8 @@ impl SemanticIndex {
|
|||
project: ModelHandle<Project>,
|
||||
phrase: String,
|
||||
limit: usize,
|
||||
include_globs: Vec<GlobMatcher>,
|
||||
exclude_globs: Vec<GlobMatcher>,
|
||||
includes: Vec<PathMatcher>,
|
||||
excludes: Vec<PathMatcher>,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) -> Task<Result<Vec<SearchResult>>> {
|
||||
let project_state = if let Some(state) = self.projects.get(&project.downgrade()) {
|
||||
|
@ -715,11 +714,8 @@ impl SemanticIndex {
|
|||
.next()
|
||||
.unwrap();
|
||||
|
||||
let file_ids = database.retrieve_included_file_ids(
|
||||
&worktree_db_ids,
|
||||
include_globs,
|
||||
exclude_globs,
|
||||
)?;
|
||||
let file_ids =
|
||||
database.retrieve_included_file_ids(&worktree_db_ids, &includes, &excludes)?;
|
||||
|
||||
let batch_n = cx.background().num_cpus();
|
||||
let ids_len = file_ids.clone().len();
|
||||
|
|
|
@ -7,11 +7,10 @@ use crate::{
|
|||
};
|
||||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use globset::Glob;
|
||||
use gpui::{Task, TestAppContext};
|
||||
use language::{Language, LanguageConfig, LanguageRegistry, ToOffset};
|
||||
use pretty_assertions::assert_eq;
|
||||
use project::{project_settings::ProjectSettings, FakeFs, Fs, Project};
|
||||
use project::{project_settings::ProjectSettings, search::PathMatcher, FakeFs, Fs, Project};
|
||||
use rand::{rngs::StdRng, Rng};
|
||||
use serde_json::json;
|
||||
use settings::SettingsStore;
|
||||
|
@ -121,8 +120,8 @@ async fn test_semantic_index(cx: &mut TestAppContext) {
|
|||
);
|
||||
|
||||
// Test Include Files Functonality
|
||||
let include_files = vec![Glob::new("*.rs").unwrap().compile_matcher()];
|
||||
let exclude_files = vec![Glob::new("*.rs").unwrap().compile_matcher()];
|
||||
let include_files = vec![PathMatcher::new("*.rs").unwrap()];
|
||||
let exclude_files = vec![PathMatcher::new("*.rs").unwrap()];
|
||||
let rust_only_search_results = store
|
||||
.update(cx, |store, cx| {
|
||||
store.search_project(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue