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
|
@ -4,7 +4,7 @@ use crate::{
|
|||
};
|
||||
use gpui::BackgroundExecutor;
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
borrow::{Borrow, Cow},
|
||||
cmp::{self, Ordering},
|
||||
iter,
|
||||
ops::Range,
|
||||
|
@ -113,14 +113,17 @@ impl Ord for StringMatch {
|
|||
}
|
||||
}
|
||||
|
||||
pub async fn match_strings(
|
||||
candidates: &[StringMatchCandidate],
|
||||
pub async fn match_strings<T>(
|
||||
candidates: &[T],
|
||||
query: &str,
|
||||
smart_case: bool,
|
||||
max_results: usize,
|
||||
cancel_flag: &AtomicBool,
|
||||
executor: BackgroundExecutor,
|
||||
) -> Vec<StringMatch> {
|
||||
) -> Vec<StringMatch>
|
||||
where
|
||||
T: Borrow<StringMatchCandidate> + Sync,
|
||||
{
|
||||
if candidates.is_empty() || max_results == 0 {
|
||||
return Default::default();
|
||||
}
|
||||
|
@ -129,10 +132,10 @@ pub async fn match_strings(
|
|||
return candidates
|
||||
.iter()
|
||||
.map(|candidate| StringMatch {
|
||||
candidate_id: candidate.id,
|
||||
candidate_id: candidate.borrow().id,
|
||||
score: 0.,
|
||||
positions: Default::default(),
|
||||
string: candidate.string.clone(),
|
||||
string: candidate.borrow().string.clone(),
|
||||
})
|
||||
.collect();
|
||||
}
|
||||
|
@ -163,10 +166,12 @@ pub async fn match_strings(
|
|||
matcher.match_candidates(
|
||||
&[],
|
||||
&[],
|
||||
candidates[segment_start..segment_end].iter(),
|
||||
candidates[segment_start..segment_end]
|
||||
.iter()
|
||||
.map(|c| c.borrow()),
|
||||
results,
|
||||
cancel_flag,
|
||||
|candidate, score, positions| StringMatch {
|
||||
|candidate: &&StringMatchCandidate, score, positions| StringMatch {
|
||||
candidate_id: candidate.id,
|
||||
score,
|
||||
positions: positions.clone(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue