Improve StringMatchCandidate::new interface (#22011)
Release Notes: - N/A
This commit is contained in:
parent
9daa426e93
commit
25970650a7
28 changed files with 92 additions and 184 deletions
|
@ -716,7 +716,7 @@ impl ContextStore {
|
||||||
let candidates = metadata
|
let candidates = metadata
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(id, metadata)| StringMatchCandidate::new(id, metadata.title.clone()))
|
.map(|(id, metadata)| StringMatchCandidate::new(id, &metadata.title))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let matches = fuzzy::match_strings(
|
let matches = fuzzy::match_strings(
|
||||||
&candidates,
|
&candidates,
|
||||||
|
|
|
@ -1439,10 +1439,7 @@ impl PromptStore {
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter_map(|(ix, metadata)| {
|
.filter_map(|(ix, metadata)| {
|
||||||
Some(StringMatchCandidate::new(
|
Some(StringMatchCandidate::new(ix, metadata.title.as_ref()?))
|
||||||
ix,
|
|
||||||
metadata.title.as_ref()?.to_string(),
|
|
||||||
))
|
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let matches = fuzzy::match_strings(
|
let matches = fuzzy::match_strings(
|
||||||
|
|
|
@ -78,11 +78,7 @@ impl SlashCommandCompletionProvider {
|
||||||
.command_names(cx)
|
.command_names(cx)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(ix, def)| StringMatchCandidate {
|
.map(|(ix, def)| StringMatchCandidate::new(ix, &def))
|
||||||
id: ix,
|
|
||||||
string: def.to_string(),
|
|
||||||
char_bag: def.as_ref().into(),
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let command_name = command_name.to_string();
|
let command_name = command_name.to_string();
|
||||||
let editor = self.editor.clone();
|
let editor = self.editor.clone();
|
||||||
|
|
|
@ -218,10 +218,7 @@ impl Options {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn match_candidates_for_args() -> [StringMatchCandidate; 1] {
|
fn match_candidates_for_args() -> [StringMatchCandidate; 1] {
|
||||||
[StringMatchCandidate::new(
|
[StringMatchCandidate::new(0, INCLUDE_WARNINGS_ARGUMENT)]
|
||||||
0,
|
|
||||||
INCLUDE_WARNINGS_ARGUMENT.to_string(),
|
|
||||||
)]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -249,11 +249,7 @@ fn tab_items_for_queries(
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter_map(|(id, (full_path, ..))| {
|
.filter_map(|(id, (full_path, ..))| {
|
||||||
let path_string = full_path.as_deref()?.to_string_lossy().to_string();
|
let path_string = full_path.as_deref()?.to_string_lossy().to_string();
|
||||||
Some(fuzzy::StringMatchCandidate {
|
Some(fuzzy::StringMatchCandidate::new(id, &path_string))
|
||||||
id,
|
|
||||||
char_bag: path_string.as_str().into(),
|
|
||||||
string: path_string,
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let mut processed_matches = HashSet::default();
|
let mut processed_matches = HashSet::default();
|
||||||
|
|
|
@ -381,11 +381,7 @@ impl MessageEditor {
|
||||||
|
|
||||||
let candidates = names
|
let candidates = names
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|user| StringMatchCandidate {
|
.map(|user| StringMatchCandidate::new(0, &user))
|
||||||
id: 0,
|
|
||||||
string: user.clone(),
|
|
||||||
char_bag: user.chars().collect(),
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
Some((start_anchor, query, candidates))
|
Some((start_anchor, query, candidates))
|
||||||
|
@ -401,11 +397,7 @@ impl MessageEditor {
|
||||||
LazyLock::new(|| {
|
LazyLock::new(|| {
|
||||||
let emojis = emojis::iter()
|
let emojis = emojis::iter()
|
||||||
.flat_map(|s| s.shortcodes())
|
.flat_map(|s| s.shortcodes())
|
||||||
.map(|emoji| StringMatchCandidate {
|
.map(|emoji| StringMatchCandidate::new(0, emoji))
|
||||||
id: 0,
|
|
||||||
string: emoji.to_string(),
|
|
||||||
char_bag: emoji.chars().collect(),
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
emojis
|
emojis
|
||||||
});
|
});
|
||||||
|
|
|
@ -393,11 +393,8 @@ impl CollabPanel {
|
||||||
// Populate the active user.
|
// Populate the active user.
|
||||||
if let Some(user) = user_store.current_user() {
|
if let Some(user) = user_store.current_user() {
|
||||||
self.match_candidates.clear();
|
self.match_candidates.clear();
|
||||||
self.match_candidates.push(StringMatchCandidate {
|
self.match_candidates
|
||||||
id: 0,
|
.push(StringMatchCandidate::new(0, &user.github_login));
|
||||||
string: user.github_login.clone(),
|
|
||||||
char_bag: user.github_login.chars().collect(),
|
|
||||||
});
|
|
||||||
let matches = executor.block(match_strings(
|
let matches = executor.block(match_strings(
|
||||||
&self.match_candidates,
|
&self.match_candidates,
|
||||||
&query,
|
&query,
|
||||||
|
@ -436,11 +433,10 @@ impl CollabPanel {
|
||||||
self.match_candidates.clear();
|
self.match_candidates.clear();
|
||||||
self.match_candidates
|
self.match_candidates
|
||||||
.extend(room.remote_participants().values().map(|participant| {
|
.extend(room.remote_participants().values().map(|participant| {
|
||||||
StringMatchCandidate {
|
StringMatchCandidate::new(
|
||||||
id: participant.user.id as usize,
|
participant.user.id as usize,
|
||||||
string: participant.user.github_login.clone(),
|
&participant.user.github_login,
|
||||||
char_bag: participant.user.github_login.chars().collect(),
|
)
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
let mut matches = executor.block(match_strings(
|
let mut matches = executor.block(match_strings(
|
||||||
&self.match_candidates,
|
&self.match_candidates,
|
||||||
|
@ -489,10 +485,8 @@ impl CollabPanel {
|
||||||
self.match_candidates.clear();
|
self.match_candidates.clear();
|
||||||
self.match_candidates
|
self.match_candidates
|
||||||
.extend(room.pending_participants().iter().enumerate().map(
|
.extend(room.pending_participants().iter().enumerate().map(
|
||||||
|(id, participant)| StringMatchCandidate {
|
|(id, participant)| {
|
||||||
id,
|
StringMatchCandidate::new(id, &participant.github_login)
|
||||||
string: participant.github_login.clone(),
|
|
||||||
char_bag: participant.github_login.chars().collect(),
|
|
||||||
},
|
},
|
||||||
));
|
));
|
||||||
let matches = executor.block(match_strings(
|
let matches = executor.block(match_strings(
|
||||||
|
@ -519,17 +513,12 @@ impl CollabPanel {
|
||||||
|
|
||||||
if channel_store.channel_count() > 0 || self.channel_editing_state.is_some() {
|
if channel_store.channel_count() > 0 || self.channel_editing_state.is_some() {
|
||||||
self.match_candidates.clear();
|
self.match_candidates.clear();
|
||||||
self.match_candidates
|
self.match_candidates.extend(
|
||||||
.extend(
|
channel_store
|
||||||
channel_store
|
.ordered_channels()
|
||||||
.ordered_channels()
|
.enumerate()
|
||||||
.enumerate()
|
.map(|(ix, (_, channel))| StringMatchCandidate::new(ix, &channel.name)),
|
||||||
.map(|(ix, (_, channel))| StringMatchCandidate {
|
);
|
||||||
id: ix,
|
|
||||||
string: channel.name.clone().into(),
|
|
||||||
char_bag: channel.name.chars().collect(),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
let matches = executor.block(match_strings(
|
let matches = executor.block(match_strings(
|
||||||
&self.match_candidates,
|
&self.match_candidates,
|
||||||
&query,
|
&query,
|
||||||
|
@ -600,14 +589,12 @@ impl CollabPanel {
|
||||||
let channel_invites = channel_store.channel_invitations();
|
let channel_invites = channel_store.channel_invitations();
|
||||||
if !channel_invites.is_empty() {
|
if !channel_invites.is_empty() {
|
||||||
self.match_candidates.clear();
|
self.match_candidates.clear();
|
||||||
self.match_candidates
|
self.match_candidates.extend(
|
||||||
.extend(channel_invites.iter().enumerate().map(|(ix, channel)| {
|
channel_invites
|
||||||
StringMatchCandidate {
|
.iter()
|
||||||
id: ix,
|
.enumerate()
|
||||||
string: channel.name.clone().into(),
|
.map(|(ix, channel)| StringMatchCandidate::new(ix, &channel.name)),
|
||||||
char_bag: channel.name.chars().collect(),
|
);
|
||||||
}
|
|
||||||
}));
|
|
||||||
let matches = executor.block(match_strings(
|
let matches = executor.block(match_strings(
|
||||||
&self.match_candidates,
|
&self.match_candidates,
|
||||||
&query,
|
&query,
|
||||||
|
@ -637,17 +624,12 @@ impl CollabPanel {
|
||||||
let incoming = user_store.incoming_contact_requests();
|
let incoming = user_store.incoming_contact_requests();
|
||||||
if !incoming.is_empty() {
|
if !incoming.is_empty() {
|
||||||
self.match_candidates.clear();
|
self.match_candidates.clear();
|
||||||
self.match_candidates
|
self.match_candidates.extend(
|
||||||
.extend(
|
incoming
|
||||||
incoming
|
.iter()
|
||||||
.iter()
|
.enumerate()
|
||||||
.enumerate()
|
.map(|(ix, user)| StringMatchCandidate::new(ix, &user.github_login)),
|
||||||
.map(|(ix, user)| StringMatchCandidate {
|
);
|
||||||
id: ix,
|
|
||||||
string: user.github_login.clone(),
|
|
||||||
char_bag: user.github_login.chars().collect(),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
let matches = executor.block(match_strings(
|
let matches = executor.block(match_strings(
|
||||||
&self.match_candidates,
|
&self.match_candidates,
|
||||||
&query,
|
&query,
|
||||||
|
@ -666,17 +648,12 @@ impl CollabPanel {
|
||||||
let outgoing = user_store.outgoing_contact_requests();
|
let outgoing = user_store.outgoing_contact_requests();
|
||||||
if !outgoing.is_empty() {
|
if !outgoing.is_empty() {
|
||||||
self.match_candidates.clear();
|
self.match_candidates.clear();
|
||||||
self.match_candidates
|
self.match_candidates.extend(
|
||||||
.extend(
|
outgoing
|
||||||
outgoing
|
.iter()
|
||||||
.iter()
|
.enumerate()
|
||||||
.enumerate()
|
.map(|(ix, user)| StringMatchCandidate::new(ix, &user.github_login)),
|
||||||
.map(|(ix, user)| StringMatchCandidate {
|
);
|
||||||
id: ix,
|
|
||||||
string: user.github_login.clone(),
|
|
||||||
char_bag: user.github_login.chars().collect(),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
let matches = executor.block(match_strings(
|
let matches = executor.block(match_strings(
|
||||||
&self.match_candidates,
|
&self.match_candidates,
|
||||||
&query,
|
&query,
|
||||||
|
@ -703,17 +680,12 @@ impl CollabPanel {
|
||||||
let contacts = user_store.contacts();
|
let contacts = user_store.contacts();
|
||||||
if !contacts.is_empty() {
|
if !contacts.is_empty() {
|
||||||
self.match_candidates.clear();
|
self.match_candidates.clear();
|
||||||
self.match_candidates
|
self.match_candidates.extend(
|
||||||
.extend(
|
contacts
|
||||||
contacts
|
.iter()
|
||||||
.iter()
|
.enumerate()
|
||||||
.enumerate()
|
.map(|(ix, contact)| StringMatchCandidate::new(ix, &contact.user.github_login)),
|
||||||
.map(|(ix, contact)| StringMatchCandidate {
|
);
|
||||||
id: ix,
|
|
||||||
string: contact.user.github_login.clone(),
|
|
||||||
char_bag: contact.user.github_login.chars().collect(),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
let matches = executor.block(match_strings(
|
let matches = executor.block(match_strings(
|
||||||
&self.match_candidates,
|
&self.match_candidates,
|
||||||
|
|
|
@ -272,11 +272,7 @@ impl PickerDelegate for ChannelModalDelegate {
|
||||||
self.match_candidates.clear();
|
self.match_candidates.clear();
|
||||||
self.match_candidates
|
self.match_candidates
|
||||||
.extend(self.members.iter().enumerate().map(|(id, member)| {
|
.extend(self.members.iter().enumerate().map(|(id, member)| {
|
||||||
StringMatchCandidate {
|
StringMatchCandidate::new(id, &member.user.github_login)
|
||||||
id,
|
|
||||||
string: member.user.github_login.clone(),
|
|
||||||
char_bag: member.user.github_login.chars().collect(),
|
|
||||||
}
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
let matches = cx.background_executor().block(match_strings(
|
let matches = cx.background_executor().block(match_strings(
|
||||||
|
|
|
@ -283,11 +283,7 @@ impl PickerDelegate for CommandPaletteDelegate {
|
||||||
let candidates = commands
|
let candidates = commands
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(ix, command)| StringMatchCandidate {
|
.map(|(ix, command)| StringMatchCandidate::new(ix, &command.name))
|
||||||
id: ix,
|
|
||||||
string: command.name.to_string(),
|
|
||||||
char_bag: command.name.chars().collect(),
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let matches = if query.is_empty() {
|
let matches = if query.is_empty() {
|
||||||
candidates
|
candidates
|
||||||
|
|
|
@ -163,7 +163,7 @@ impl CompletionsMenu {
|
||||||
.map(|(id, completion)| {
|
.map(|(id, completion)| {
|
||||||
StringMatchCandidate::new(
|
StringMatchCandidate::new(
|
||||||
id,
|
id,
|
||||||
completion.label.text[completion.label.filter_range.clone()].into(),
|
&completion.label.text[completion.label.filter_range.clone()],
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
@ -211,7 +211,7 @@ impl CompletionsMenu {
|
||||||
let match_candidates = choices
|
let match_candidates = choices
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(id, completion)| StringMatchCandidate::new(id, completion.to_string()))
|
.map(|(id, completion)| StringMatchCandidate::new(id, &completion))
|
||||||
.collect();
|
.collect();
|
||||||
let matches = choices
|
let matches = choices
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
@ -13293,7 +13293,7 @@ fn snippet_completions(
|
||||||
snippet
|
snippet
|
||||||
.prefix
|
.prefix
|
||||||
.iter()
|
.iter()
|
||||||
.map(move |prefix| StringMatchCandidate::new(ix, prefix.clone()))
|
.map(move |prefix| StringMatchCandidate::new(ix, &prefix))
|
||||||
})
|
})
|
||||||
.collect::<Vec<StringMatchCandidate>>();
|
.collect::<Vec<StringMatchCandidate>>();
|
||||||
|
|
||||||
|
|
|
@ -113,13 +113,7 @@ impl PickerDelegate for ExtensionVersionSelectorDelegate {
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(id, extension)| {
|
.map(|(id, extension)| {
|
||||||
let text = format!("v{}", extension.manifest.version);
|
StringMatchCandidate::new(id, &format!("v{}", extension.manifest.version))
|
||||||
|
|
||||||
StringMatchCandidate {
|
|
||||||
id,
|
|
||||||
char_bag: text.as_str().into(),
|
|
||||||
string: text,
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
|
|
@ -328,11 +328,7 @@ impl ExtensionsPage {
|
||||||
let match_candidates = dev_extensions
|
let match_candidates = dev_extensions
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(ix, manifest)| StringMatchCandidate {
|
.map(|(ix, manifest)| StringMatchCandidate::new(ix, &manifest.name))
|
||||||
id: ix,
|
|
||||||
string: manifest.name.clone(),
|
|
||||||
char_bag: manifest.name.as_str().into(),
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let matches = match_strings(
|
let matches = match_strings(
|
||||||
|
|
|
@ -131,7 +131,7 @@ impl PickerDelegate for OpenPathDelegate {
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(ix, path)| {
|
.map(|(ix, path)| {
|
||||||
StringMatchCandidate::new(ix, path.to_string_lossy().into())
|
StringMatchCandidate::new(ix, &path.to_string_lossy())
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
|
|
@ -18,22 +18,12 @@ pub struct StringMatchCandidate {
|
||||||
pub char_bag: CharBag,
|
pub char_bag: CharBag,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Match for StringMatch {
|
|
||||||
fn score(&self) -> f64 {
|
|
||||||
self.score
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_positions(&mut self, positions: Vec<usize>) {
|
|
||||||
self.positions = positions;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl StringMatchCandidate {
|
impl StringMatchCandidate {
|
||||||
pub fn new(id: usize, string: String) -> Self {
|
pub fn new(id: usize, string: &str) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id,
|
id,
|
||||||
char_bag: CharBag::from(string.as_str()),
|
string: string.into(),
|
||||||
string,
|
char_bag: string.into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,6 +46,16 @@ pub struct StringMatch {
|
||||||
pub string: String,
|
pub string: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Match for StringMatch {
|
||||||
|
fn score(&self) -> f64 {
|
||||||
|
self.score
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_positions(&mut self, positions: Vec<usize>) {
|
||||||
|
self.positions = positions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl StringMatch {
|
impl StringMatch {
|
||||||
pub fn ranges(&self) -> impl '_ + Iterator<Item = Range<usize>> {
|
pub fn ranges(&self) -> impl '_ + Iterator<Item = Range<usize>> {
|
||||||
let mut positions = self.positions.iter().peekable();
|
let mut positions = self.positions.iter().peekable();
|
||||||
|
|
|
@ -208,7 +208,7 @@ impl IndexedDocsStore {
|
||||||
let candidates = items
|
let candidates = items
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(ix, item_path)| StringMatchCandidate::new(ix, item_path.clone()))
|
.map(|(ix, item_path)| StringMatchCandidate::new(ix, &item_path))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let matches = fuzzy::match_strings(
|
let matches = fuzzy::match_strings(
|
||||||
|
|
|
@ -73,8 +73,8 @@ impl<T> Outline<T> {
|
||||||
.map(|range| &item.text[range.start..range.end])
|
.map(|range| &item.text[range.start..range.end])
|
||||||
.collect::<String>();
|
.collect::<String>();
|
||||||
|
|
||||||
path_candidates.push(StringMatchCandidate::new(id, path_text.clone()));
|
path_candidates.push(StringMatchCandidate::new(id, &path_text));
|
||||||
candidates.push(StringMatchCandidate::new(id, candidate_text));
|
candidates.push(StringMatchCandidate::new(id, &candidate_text));
|
||||||
}
|
}
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
|
|
@ -112,7 +112,7 @@ impl LanguageSelectorDelegate {
|
||||||
.then_some(name)
|
.then_some(name)
|
||||||
})
|
})
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(candidate_id, name)| StringMatchCandidate::new(candidate_id, name))
|
.map(|(candidate_id, name)| StringMatchCandidate::new(candidate_id, &name))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
|
|
@ -3296,40 +3296,32 @@ impl OutlinePanel {
|
||||||
if let Some(file_name) =
|
if let Some(file_name) =
|
||||||
self.relative_path(fs_entry, cx).as_deref().map(file_name)
|
self.relative_path(fs_entry, cx).as_deref().map(file_name)
|
||||||
{
|
{
|
||||||
state.match_candidates.push(StringMatchCandidate {
|
state
|
||||||
id,
|
.match_candidates
|
||||||
string: file_name.to_string(),
|
.push(StringMatchCandidate::new(id, &file_name));
|
||||||
char_bag: file_name.chars().collect(),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PanelEntry::FoldedDirs(worktree_id, entries) => {
|
PanelEntry::FoldedDirs(worktree_id, entries) => {
|
||||||
let dir_names = self.dir_names_string(entries, *worktree_id, cx);
|
let dir_names = self.dir_names_string(entries, *worktree_id, cx);
|
||||||
{
|
{
|
||||||
state.match_candidates.push(StringMatchCandidate {
|
state
|
||||||
id,
|
.match_candidates
|
||||||
string: dir_names.clone(),
|
.push(StringMatchCandidate::new(id, &dir_names));
|
||||||
char_bag: dir_names.chars().collect(),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PanelEntry::Outline(outline_entry) => match outline_entry {
|
PanelEntry::Outline(outline_entry) => match outline_entry {
|
||||||
OutlineEntry::Outline(_, _, outline) => {
|
OutlineEntry::Outline(_, _, outline) => {
|
||||||
state.match_candidates.push(StringMatchCandidate {
|
state
|
||||||
id,
|
.match_candidates
|
||||||
string: outline.text.clone(),
|
.push(StringMatchCandidate::new(id, &outline.text));
|
||||||
char_bag: outline.text.chars().collect(),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
OutlineEntry::Excerpt(..) => {}
|
OutlineEntry::Excerpt(..) => {}
|
||||||
},
|
},
|
||||||
PanelEntry::Search(new_search_entry) => {
|
PanelEntry::Search(new_search_entry) => {
|
||||||
if let Some(search_data) = new_search_entry.render_data.get() {
|
if let Some(search_data) = new_search_entry.render_data.get() {
|
||||||
state.match_candidates.push(StringMatchCandidate {
|
state
|
||||||
id,
|
.match_candidates
|
||||||
char_bag: search_data.context_text.chars().collect(),
|
.push(StringMatchCandidate::new(id, &search_data.context_text));
|
||||||
string: search_data.context_text.clone(),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -179,7 +179,7 @@ impl PickerDelegate for ProjectSymbolsDelegate {
|
||||||
.map(|(id, symbol)| {
|
.map(|(id, symbol)| {
|
||||||
StringMatchCandidate::new(
|
StringMatchCandidate::new(
|
||||||
id,
|
id,
|
||||||
symbol.label.text[symbol.label.filter_range.clone()].to_string(),
|
&symbol.label.text[symbol.label.filter_range.clone()],
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.partition(|candidate| {
|
.partition(|candidate| {
|
||||||
|
@ -313,7 +313,7 @@ mod tests {
|
||||||
let candidates = fake_symbols
|
let candidates = fake_symbols
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(id, symbol)| StringMatchCandidate::new(id, symbol.name.clone()))
|
.map(|(id, symbol)| StringMatchCandidate::new(id, &symbol.name))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let matches = if params.query.is_empty() {
|
let matches = if params.query.is_empty() {
|
||||||
Vec::new()
|
Vec::new()
|
||||||
|
|
|
@ -228,7 +228,7 @@ impl PickerDelegate for RecentProjectsDelegate {
|
||||||
.join(""),
|
.join(""),
|
||||||
};
|
};
|
||||||
|
|
||||||
StringMatchCandidate::new(id, combined_string)
|
StringMatchCandidate::new(id, &combined_string)
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
self.matches = smol::block_on(fuzzy::match_strings(
|
self.matches = smol::block_on(fuzzy::match_strings(
|
||||||
|
|
|
@ -96,7 +96,7 @@ impl ScopeSelectorDelegate {
|
||||||
let candidates = candidates
|
let candidates = candidates
|
||||||
.chain(languages)
|
.chain(languages)
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(candidate_id, name)| StringMatchCandidate::new(candidate_id, name))
|
.map(|(candidate_id, name)| StringMatchCandidate::new(candidate_id, &name))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
|
|
|
@ -22,11 +22,7 @@ impl Delegate {
|
||||||
.iter()
|
.iter()
|
||||||
.copied()
|
.copied()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(id, string)| StringMatchCandidate {
|
.map(|(id, string)| StringMatchCandidate::new(id, string))
|
||||||
id,
|
|
||||||
char_bag: string.into(),
|
|
||||||
string: string.into(),
|
|
||||||
})
|
|
||||||
.collect(),
|
.collect(),
|
||||||
matches: vec![],
|
matches: vec![],
|
||||||
selected_ix: 0,
|
selected_ix: 0,
|
||||||
|
|
|
@ -516,7 +516,7 @@ fn string_match_candidates<'a>(
|
||||||
.map(|(index, (_, candidate))| StringMatchCandidate {
|
.map(|(index, (_, candidate))| StringMatchCandidate {
|
||||||
id: index,
|
id: index,
|
||||||
char_bag: candidate.resolved_label.chars().collect(),
|
char_bag: candidate.resolved_label.chars().collect(),
|
||||||
string: candidate.display_label().to_owned(),
|
string: candidate.display_label().into(),
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,11 +230,7 @@ impl PickerDelegate for ThemeSelectorDelegate {
|
||||||
.themes
|
.themes
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(id, meta)| StringMatchCandidate {
|
.map(|(id, meta)| StringMatchCandidate::new(id, &meta.name))
|
||||||
id,
|
|
||||||
char_bag: meta.name.as_ref().into(),
|
|
||||||
string: meta.name.to_string(),
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
cx.spawn(|this, mut cx| async move {
|
cx.spawn(|this, mut cx| async move {
|
||||||
|
|
|
@ -296,7 +296,7 @@ impl PickerDelegate for ToolchainSelectorDelegate {
|
||||||
.map(|(candidate_id, toolchain)| {
|
.map(|(candidate_id, toolchain)| {
|
||||||
let path = Self::relativize_path(toolchain.path, &worktree_root_path);
|
let path = Self::relativize_path(toolchain.path, &worktree_root_path);
|
||||||
let string = format!("{}{}", toolchain.name, path);
|
let string = format!("{}{}", toolchain.name, path);
|
||||||
StringMatchCandidate::new(candidate_id, string)
|
StringMatchCandidate::new(candidate_id, &string)
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
match_strings(
|
match_strings(
|
||||||
|
|
|
@ -172,11 +172,7 @@ impl PickerDelegate for BranchListDelegate {
|
||||||
branches
|
branches
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(ix, command)| StringMatchCandidate {
|
.map(|(ix, command)| StringMatchCandidate::new(ix, &command.name))
|
||||||
id: ix,
|
|
||||||
char_bag: command.name.chars().collect(),
|
|
||||||
string: command.name.into(),
|
|
||||||
})
|
|
||||||
.collect::<Vec<StringMatchCandidate>>()
|
.collect::<Vec<StringMatchCandidate>>()
|
||||||
});
|
});
|
||||||
let Some(candidates) = candidates.log_err() else {
|
let Some(candidates) = candidates.log_err() else {
|
||||||
|
|
|
@ -127,11 +127,7 @@ impl PickerDelegate for BaseKeymapSelectorDelegate {
|
||||||
let background = cx.background_executor().clone();
|
let background = cx.background_executor().clone();
|
||||||
let candidates = BaseKeymap::names()
|
let candidates = BaseKeymap::names()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(id, name)| StringMatchCandidate {
|
.map(|(id, name)| StringMatchCandidate::new(id, name))
|
||||||
id,
|
|
||||||
char_bag: name.into(),
|
|
||||||
string: name.into(),
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
cx.spawn(|this, mut cx| async move {
|
cx.spawn(|this, mut cx| async move {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue