workspace: Add trailing / to directories on completion when using OpenPathPrompt (#25430)

Closes #25045

With the setting `"use_system_path_prompts": false`, previously, if the
completion target was a directory, no separator would be added after it,
requiring us to manually append a `/` or `\`. Now, if the completion
target is a directory, a `/` or `\` will be automatically added. On
Windows, both `/` and `\` are considered valid path separators.



https://github.com/user-attachments/assets/0594ce27-9693-4a49-ae0e-3ed29f62526a



Release Notes:

- N/A
This commit is contained in:
张小白 2025-03-04 14:01:08 +08:00 committed by GitHub
parent 8c4da9fba0
commit 11b79d0ab9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 472 additions and 41 deletions

View file

@ -554,15 +554,29 @@ impl HeadlessProject {
) -> Result<proto::ListRemoteDirectoryResponse> {
let fs = cx.read_entity(&this, |this, _| this.fs.clone())?;
let expanded = PathBuf::from_proto(shellexpand::tilde(&envelope.payload.path).to_string());
let check_info = envelope
.payload
.config
.as_ref()
.is_some_and(|config| config.is_dir);
let mut entries = Vec::new();
let mut entry_info = Vec::new();
let mut response = fs.read_dir(&expanded).await?;
while let Some(path) = response.next().await {
if let Some(file_name) = path?.file_name() {
let path = path?;
if let Some(file_name) = path.file_name() {
entries.push(file_name.to_string_lossy().to_string());
if check_info {
let is_dir = fs.is_dir(&path).await;
entry_info.push(proto::EntryInfo { is_dir });
}
}
}
Ok(proto::ListRemoteDirectoryResponse { entries })
Ok(proto::ListRemoteDirectoryResponse {
entries,
entry_info,
})
}
pub async fn handle_get_path_metadata(