assistant2: Fix \\ appearing for paths in file context picker (#27528)

Closes #ISSUE

Release Notes:

- N/A
This commit is contained in:
Bennet Bo Fenner 2025-03-26 21:22:13 +01:00 committed by GitHub
parent 13bf179aae
commit 8b3ddcd545
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -282,7 +282,10 @@ pub fn render_file_context_entry(
cx: &App, cx: &App,
) -> Stateful<Div> { ) -> Stateful<Div> {
let (file_name, directory) = if path == Path::new("") { 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 { } else {
let file_name = path let file_name = path
.file_name() .file_name()
@ -291,8 +294,10 @@ pub fn render_file_context_entry(
.to_string() .to_string()
.into(); .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("")) { if let Some(parent) = path.parent().filter(|parent| parent != &Path::new("")) {
directory.push_str(&parent.to_string_lossy()); directory.push_str(&parent.to_string_lossy());
directory.push('/'); directory.push('/');