diff --git a/crates/tabby-common/src/api/code.rs b/crates/tabby-common/src/api/code.rs index a3fb3799b53e..daf696ae883f 100644 --- a/crates/tabby-common/src/api/code.rs +++ b/crates/tabby-common/src/api/code.rs @@ -4,6 +4,7 @@ use async_trait::async_trait; use derive_builder::Builder; use serde::{Deserialize, Serialize}; use thiserror::Error; +use tracing::debug; use crate::path::normalize_path; @@ -67,8 +68,15 @@ impl CodeSearchQuery { content: String, source_id: String, ) -> Self { + debug!("CodeSearchQuery::new - Original filepath: {:?}", filepath); + let normalized = normalize_path(filepath).unwrap_or(None); + debug!( + "CodeSearchQuery::new - Normalized filepath: {:?}", + normalized + ); + Self { - filepath: normalize_path(filepath).unwrap_or(None), + filepath: normalized, language, content, source_id, diff --git a/crates/tabby-common/src/index/code/mod.rs b/crates/tabby-common/src/index/code/mod.rs index ce70bcee19f7..ac57c84caa52 100644 --- a/crates/tabby-common/src/index/code/mod.rs +++ b/crates/tabby-common/src/index/code/mod.rs @@ -5,6 +5,7 @@ use tantivy::{ Term, }; pub use tokenizer::tokenize_code; +use tracing::debug; use super::{corpus, IndexSchema}; use crate::{api::code::CodeSearchQuery, path::normalize_path}; @@ -49,15 +50,16 @@ pub fn body_query(tokens: &[String]) -> Box { } fn filepath_query(filepath: &str) -> Box { + debug!("filepath_query - Input filepath: {}", filepath); let schema = IndexSchema::instance(); let mut term = Term::from_field_json_path(schema.field_chunk_attributes, fields::CHUNK_FILEPATH, false); - // normalize the path base on the platform. let filepath = normalize_path(Some(filepath.to_string())) .ok() .flatten() .unwrap_or_else(|| filepath.to_string()); + debug!("filepath_query - Normalized filepath: {}", filepath); term.append_type_and_str(&filepath); Box::new(TermQuery::new(term, IndexRecordOption::Basic)) @@ -91,7 +93,12 @@ pub fn code_search_query( // When filepath presents, we exclude the file from the search. if let Some(filepath) = &query.filepath { + debug!("code_search_query - Original filepath: {}", filepath); if let Ok(Some(normalized_path)) = normalize_path(Some(filepath.clone())) { + debug!( + "code_search_query - Normalized filepath: {}", + normalized_path + ); subqueries.push(( Occur::MustNot, Box::new(ConstScoreQuery::new(filepath_query(&normalized_path), 0.0)),