Improve slash commands (#16195)
This PR: - Makes slash commands easier to compose by adding a concept, `CompletionIntent`. When using `tab` on a completion in the assistant panel, that completion item will be expanded but the associated command will not be run. Using `enter` will still either run the completion item or continue command composition as before. - Fixes a bug where running `/diagnostics` on a project with no diagnostics will delete the entire command, rather than rendering an empty header. - Improves the autocomplete rendering for files, showing when directories are selected and re-arranging the results to have the file name or trailing directory show first. <img width="642" alt="Screenshot 2024-08-13 at 8 12 43 PM" src="https://github.com/user-attachments/assets/97c96cd2-741f-4f15-ad03-7cf78129a71c"> Release Notes: - N/A
This commit is contained in:
parent
5cb4de4ec6
commit
97469cd049
23 changed files with 326 additions and 190 deletions
|
@ -182,7 +182,7 @@ impl SlashCommand for DocsSlashCommand {
|
|||
items
|
||||
.into_iter()
|
||||
.map(|item| ArgumentCompletion {
|
||||
label: item.clone(),
|
||||
label: item.clone().into(),
|
||||
new_text: format!("{provider} {item}"),
|
||||
run_command: true,
|
||||
})
|
||||
|
@ -194,7 +194,7 @@ impl SlashCommand for DocsSlashCommand {
|
|||
let providers = indexed_docs_registry.list_providers();
|
||||
if providers.is_empty() {
|
||||
return Ok(vec![ArgumentCompletion {
|
||||
label: "No available docs providers.".to_string(),
|
||||
label: "No available docs providers.".into(),
|
||||
new_text: String::new(),
|
||||
run_command: false,
|
||||
}]);
|
||||
|
@ -203,7 +203,7 @@ impl SlashCommand for DocsSlashCommand {
|
|||
Ok(providers
|
||||
.into_iter()
|
||||
.map(|provider| ArgumentCompletion {
|
||||
label: provider.to_string(),
|
||||
label: provider.to_string().into(),
|
||||
new_text: provider.to_string(),
|
||||
run_command: false,
|
||||
})
|
||||
|
@ -231,10 +231,10 @@ impl SlashCommand for DocsSlashCommand {
|
|||
.filter(|package_name| {
|
||||
!items
|
||||
.iter()
|
||||
.any(|item| item.label.as_str() == package_name.as_ref())
|
||||
.any(|item| item.label.text() == package_name.as_ref())
|
||||
})
|
||||
.map(|package_name| ArgumentCompletion {
|
||||
label: format!("{package_name} (unindexed)"),
|
||||
label: format!("{package_name} (unindexed)").into(),
|
||||
new_text: format!("{provider} {package_name}"),
|
||||
run_command: true,
|
||||
})
|
||||
|
@ -246,7 +246,8 @@ impl SlashCommand for DocsSlashCommand {
|
|||
label: format!(
|
||||
"Enter a {package_term} name.",
|
||||
package_term = package_term(&provider)
|
||||
),
|
||||
)
|
||||
.into(),
|
||||
new_text: provider.to_string(),
|
||||
run_command: false,
|
||||
}]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue