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
co-authored by Marshall Bowers
parent 88a12b60a9
commit 8fe2de1737
23 changed files with 332 additions and 263 deletions
+6 -6
View File
@@ -114,7 +114,7 @@ pub trait Extension: Send + Sync {
fn complete_slash_command_argument(
&self,
_command: SlashCommand,
_query: String,
_args: Vec<String>,
) -> Result<Vec<SlashCommandArgumentCompletion>, String> {
Ok(Vec::new())
}
@@ -123,7 +123,7 @@ pub trait Extension: Send + Sync {
fn run_slash_command(
&self,
_command: SlashCommand,
_argument: Option<String>,
_args: Vec<String>,
_worktree: Option<&Worktree>,
) -> Result<SlashCommandOutput, String> {
Err("`run_slash_command` not implemented".to_string())
@@ -257,17 +257,17 @@ impl wit::Guest for Component {
fn complete_slash_command_argument(
command: SlashCommand,
query: String,
args: Vec<String>,
) -> Result<Vec<SlashCommandArgumentCompletion>, String> {
extension().complete_slash_command_argument(command, query)
extension().complete_slash_command_argument(command, args)
}
fn run_slash_command(
command: SlashCommand,
argument: Option<String>,
args: Vec<String>,
worktree: Option<&Worktree>,
) -> Result<SlashCommandOutput, String> {
extension().run_slash_command(command, argument, worktree)
extension().run_slash_command(command, args, worktree)
}
fn suggest_docs_packages(provider: String) -> Result<Vec<String>, String> {
@@ -130,10 +130,10 @@ world extension {
export labels-for-symbols: func(language-server-id: string, symbols: list<symbol>) -> result<list<option<code-label>>, string>;
/// Returns the completions that should be shown when completing the provided slash command with the given query.
export complete-slash-command-argument: func(command: slash-command, query: string) -> result<list<slash-command-argument-completion>, string>;
export complete-slash-command-argument: func(command: slash-command, args: list<string>) -> result<list<slash-command-argument-completion>, string>;
/// Returns the output from running the provided slash command.
export run-slash-command: func(command: slash-command, argument: option<string>, worktree: option<borrow<worktree>>) -> result<slash-command-output, string>;
export run-slash-command: func(command: slash-command, args: list<string>, worktree: option<borrow<worktree>>) -> result<slash-command-output, string>;
/// Returns a list of packages as suggestions to be included in the `/docs`
/// search results.