Further improve /tabs command and slash arguments completion (#16216)

* renames `/tabs` to `/tab`
* allows to insert multiple tabs when fuzzy matching by the names
* improve slash command completion API, introduce a notion of multiple
arguments
* properly fire off commands on arguments' completions with
`run_command: true`

Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <marshall@zed.dev>
This commit is contained in:
Kirill Bulatov 2024-08-14 17:11:51 +03:00 committed by GitHub
parent 88a12b60a9
commit 8fe2de1737
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
23 changed files with 332 additions and 263 deletions

View file

@ -49,7 +49,7 @@ impl SlashCommand for SearchSlashCommand {
fn complete_argument(
self: Arc<Self>,
_query: String,
_arguments: &[String],
_cancel: Arc<AtomicBool>,
_workspace: Option<WeakView<Workspace>>,
_cx: &mut WindowContext,
@ -59,7 +59,7 @@ impl SlashCommand for SearchSlashCommand {
fn run(
self: Arc<Self>,
argument: Option<&str>,
arguments: &[String],
workspace: WeakView<Workspace>,
_delegate: Option<Arc<dyn LspAdapterDelegate>>,
cx: &mut WindowContext,
@ -67,13 +67,13 @@ impl SlashCommand for SearchSlashCommand {
let Some(workspace) = workspace.upgrade() else {
return Task::ready(Err(anyhow::anyhow!("workspace was dropped")));
};
let Some(argument) = argument else {
if arguments.is_empty() {
return Task::ready(Err(anyhow::anyhow!("missing search query")));
};
let mut limit = None;
let mut query = String::new();
for part in argument.split(' ') {
for part in arguments {
if let Some(parameter) = part.strip_prefix("--") {
if let Ok(count) = parameter.parse::<usize>() {
limit = Some(count);