From 8b3ddcd54596e2cce747380cb7cf43f1d8b3f2bf Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Wed, 26 Mar 2025 21:22:13 +0100 Subject: [PATCH] assistant2: Fix `\\` appearing for paths in file context picker (#27528) Closes #ISSUE Release Notes: - N/A --- .../src/context_picker/file_context_picker.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/crates/assistant2/src/context_picker/file_context_picker.rs b/crates/assistant2/src/context_picker/file_context_picker.rs index 572987f8af..65bbb4e302 100644 --- a/crates/assistant2/src/context_picker/file_context_picker.rs +++ b/crates/assistant2/src/context_picker/file_context_picker.rs @@ -282,7 +282,10 @@ pub fn render_file_context_entry( cx: &App, ) -> Stateful
{ let (file_name, directory) = if path == Path::new("") { - (SharedString::from(path_prefix.clone()), None) + ( + SharedString::from(path_prefix.trim_end_matches('/').to_string()), + None, + ) } else { let file_name = path .file_name() @@ -291,8 +294,10 @@ pub fn render_file_context_entry( .to_string() .into(); - let mut directory = format!("{}/", path_prefix); - + let mut directory = path_prefix.to_string(); + if !directory.ends_with('/') { + directory.push('/'); + } if let Some(parent) = path.parent().filter(|parent| parent != &Path::new("")) { directory.push_str(&parent.to_string_lossy()); directory.push('/');