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:
parent
8c4da9fba0
commit
11b79d0ab9
8 changed files with 472 additions and 41 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue