sort plugins first in menu (#14163)
we want plugin mentions to show up before others, like apps and skills. updated tests.
This commit is contained in:
parent
aa04ea6bd7
commit
a3cd9f16f5
3 changed files with 19 additions and 13 deletions
|
|
@ -3580,6 +3580,7 @@ impl ChatComposer {
|
|||
search_terms,
|
||||
path: Some(skill.path_to_skills_md.to_string_lossy().into_owned()),
|
||||
category_tag: Some("[Skill]".to_string()),
|
||||
sort_rank: 1,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -3631,6 +3632,7 @@ impl ChatComposer {
|
|||
search_terms,
|
||||
path: Some(format!("plugin://{}", plugin.config_name)),
|
||||
category_tag: Some("[Plugin]".to_string()),
|
||||
sort_rank: 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -3654,6 +3656,7 @@ impl ChatComposer {
|
|||
search_terms,
|
||||
path: Some(format!("app://{connector_id}")),
|
||||
category_tag: Some("[App]".to_string()),
|
||||
sort_rank: 1,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ pub(crate) struct MentionItem {
|
|||
pub(crate) search_terms: Vec<String>,
|
||||
pub(crate) path: Option<String>,
|
||||
pub(crate) category_tag: Option<String>,
|
||||
pub(crate) sort_rank: u8,
|
||||
}
|
||||
|
||||
const MENTION_NAME_TRUNCATE_LEN: usize = 24;
|
||||
|
|
@ -130,14 +131,12 @@ impl SkillPopup {
|
|||
let filter = self.query.trim();
|
||||
let mut out: Vec<(usize, Option<Vec<usize>>, i32)> = Vec::new();
|
||||
|
||||
if filter.is_empty() {
|
||||
for (idx, _mention) in self.mentions.iter().enumerate() {
|
||||
out.push((idx, None, 0));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
for (idx, mention) in self.mentions.iter().enumerate() {
|
||||
if filter.is_empty() {
|
||||
out.push((idx, None, 0));
|
||||
continue;
|
||||
}
|
||||
|
||||
let mut best_match: Option<(Option<Vec<usize>>, i32)> = None;
|
||||
|
||||
if let Some((indices, score)) = fuzzy_match(&mention.display_name, filter) {
|
||||
|
|
@ -170,11 +169,15 @@ impl SkillPopup {
|
|||
}
|
||||
|
||||
out.sort_by(|a, b| {
|
||||
a.2.cmp(&b.2).then_with(|| {
|
||||
let an = self.mentions[a.0].display_name.as_str();
|
||||
let bn = self.mentions[b.0].display_name.as_str();
|
||||
an.cmp(bn)
|
||||
})
|
||||
self.mentions[a.0]
|
||||
.sort_rank
|
||||
.cmp(&self.mentions[b.0].sort_rank)
|
||||
.then_with(|| a.2.cmp(&b.2))
|
||||
.then_with(|| {
|
||||
let an = self.mentions[a.0].display_name.as_str();
|
||||
let bn = self.mentions[b.0].display_name.as_str();
|
||||
an.cmp(bn)
|
||||
})
|
||||
});
|
||||
|
||||
out
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ expression: terminal.backend()
|
|||
"› $goog "
|
||||
" "
|
||||
" "
|
||||
" Google Calendar [Skill] Find availability and plan event changes "
|
||||
" Google Calendar [Plugin] Connect Google Calendar for scheduling, ava…"
|
||||
" Google Calendar [Skill] Find availability and plan event changes "
|
||||
" Google Calendar [App] Look up events and availability "
|
||||
" "
|
||||
" Press enter to insert or esc to close "
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue