diff --git a/crates/tabby-common/src/api/code.rs b/crates/tabby-common/src/api/code.rs index fe7b8c1e242e..cd9610b748a5 100644 --- a/crates/tabby-common/src/api/code.rs +++ b/crates/tabby-common/src/api/code.rs @@ -3,8 +3,6 @@ use derive_builder::Builder; use serde::{Deserialize, Serialize}; use thiserror::Error; -use crate::path::normalize_to_unix_path; - pub struct CodeSearchResponse { pub hits: Vec, } @@ -109,3 +107,33 @@ pub trait CodeSearch: Send + Sync { params: CodeSearchParams, ) -> Result; } + +/// Normalize the path form different platform to unix style path +pub fn normalize_to_unix_path(filepath: Option) -> anyhow::Result> { + Ok(filepath.map(|path| path.replace('\\', "/"))) +} +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_relative_path_normalization() { + let unix_test_cases = [ + ("./src/main.rs", "./src/main.rs"), + (".\\src\\main.rs", "./src/main.rs"), + ("../test/data.json", "../test/data.json"), + ("..\\test\\data.json", "../test/data.json"), + ("src/test/file.txt", "src/test/file.txt"), + ("src\\test\\file.txt", "src/test/file.txt"), + ]; + + for (input, expected) in unix_test_cases { + assert_eq!( + normalize_to_unix_path(Some(input.to_string())).unwrap(), + Some(expected.to_string()), + "Failed to normalize path: {}", + input + ); + } + } +} diff --git a/crates/tabby-common/src/path.rs b/crates/tabby-common/src/path.rs index 7c81226fcd15..81b467f1a827 100644 --- a/crates/tabby-common/src/path.rs +++ b/crates/tabby-common/src/path.rs @@ -1,6 +1,5 @@ use std::{cell::Cell, env, path::PathBuf, sync::Mutex}; -use anyhow::Result; use lazy_static::lazy_static; lazy_static! { @@ -54,35 +53,4 @@ pub fn events_dir() -> PathBuf { tabby_root().join("events") } -/// Normalize the path form different platform to unix style path -pub fn normalize_to_unix_path(filepath: Option) -> Result> { - Ok(filepath.map(|path| path.replace('\\', "/"))) -} - mod registry {} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn test_relative_path_normalization() { - let unix_test_cases = [ - ("./src/main.rs", "./src/main.rs"), - (".\\src\\main.rs", "./src/main.rs"), - ("../test/data.json", "../test/data.json"), - ("..\\test\\data.json", "../test/data.json"), - ("src/test/file.txt", "src/test/file.txt"), - ("src\\test\\file.txt", "src/test/file.txt"), - ]; - - for (input, expected) in unix_test_cases { - assert_eq!( - normalize_to_unix_path(Some(input.to_string())).unwrap(), - Some(expected.to_string()), - "Failed to normalize path: {}", - input - ); - } - } -} diff --git a/crates/tabby/src/services/completion.rs b/crates/tabby/src/services/completion.rs index c74db00e91e6..b771bf82d909 100644 --- a/crates/tabby/src/services/completion.rs +++ b/crates/tabby/src/services/completion.rs @@ -113,7 +113,6 @@ pub struct Segments { suffix: Option, /// The relative path of the file that is being edited. - /// The filepath will keep the same format as the original file path base on the platform. /// - When [Segments::git_url] is set, this is the path of the file in the git repository. /// - When [Segments::git_url] is empty, this is the path of the file in the workspace. filepath: Option,