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:
parent
88a12b60a9
commit
8fe2de1737
23 changed files with 332 additions and 263 deletions
|
@ -39,11 +39,12 @@ impl SlashCommand for ExtensionSlashCommand {
|
|||
|
||||
fn complete_argument(
|
||||
self: Arc<Self>,
|
||||
query: String,
|
||||
arguments: &[String],
|
||||
_cancel: Arc<AtomicBool>,
|
||||
_workspace: Option<WeakView<Workspace>>,
|
||||
cx: &mut WindowContext,
|
||||
) -> Task<Result<Vec<ArgumentCompletion>>> {
|
||||
let arguments = arguments.to_owned();
|
||||
cx.background_executor().spawn(async move {
|
||||
self.extension
|
||||
.call({
|
||||
|
@ -54,7 +55,7 @@ impl SlashCommand for ExtensionSlashCommand {
|
|||
.call_complete_slash_command_argument(
|
||||
store,
|
||||
&this.command,
|
||||
query.as_ref(),
|
||||
&arguments,
|
||||
)
|
||||
.await?
|
||||
.map_err(|e| anyhow!("{}", e))?;
|
||||
|
@ -79,12 +80,12 @@ impl SlashCommand for ExtensionSlashCommand {
|
|||
|
||||
fn run(
|
||||
self: Arc<Self>,
|
||||
argument: Option<&str>,
|
||||
arguments: &[String],
|
||||
_workspace: WeakView<Workspace>,
|
||||
delegate: Option<Arc<dyn LspAdapterDelegate>>,
|
||||
cx: &mut WindowContext,
|
||||
) -> Task<Result<SlashCommandOutput>> {
|
||||
let argument = argument.map(|arg| arg.to_string());
|
||||
let arguments = arguments.to_owned();
|
||||
let output = cx.background_executor().spawn(async move {
|
||||
self.extension
|
||||
.call({
|
||||
|
@ -97,12 +98,7 @@ impl SlashCommand for ExtensionSlashCommand {
|
|||
None
|
||||
};
|
||||
let output = extension
|
||||
.call_run_slash_command(
|
||||
store,
|
||||
&this.command,
|
||||
argument.as_deref(),
|
||||
resource,
|
||||
)
|
||||
.call_run_slash_command(store, &this.command, &arguments, resource)
|
||||
.await?
|
||||
.map_err(|e| anyhow!("{}", e))?;
|
||||
|
||||
|
|
|
@ -262,11 +262,11 @@ impl Extension {
|
|||
&self,
|
||||
store: &mut Store<WasmState>,
|
||||
command: &SlashCommand,
|
||||
query: &str,
|
||||
arguments: &[String],
|
||||
) -> Result<Result<Vec<SlashCommandArgumentCompletion>, String>> {
|
||||
match self {
|
||||
Extension::V010(ext) => {
|
||||
ext.call_complete_slash_command_argument(store, command, query)
|
||||
ext.call_complete_slash_command_argument(store, command, arguments)
|
||||
.await
|
||||
}
|
||||
Extension::V001(_) | Extension::V004(_) | Extension::V006(_) => Ok(Ok(Vec::new())),
|
||||
|
@ -277,12 +277,12 @@ impl Extension {
|
|||
&self,
|
||||
store: &mut Store<WasmState>,
|
||||
command: &SlashCommand,
|
||||
argument: Option<&str>,
|
||||
arguments: &[String],
|
||||
resource: Option<Resource<Arc<dyn LspAdapterDelegate>>>,
|
||||
) -> Result<Result<SlashCommandOutput, String>> {
|
||||
match self {
|
||||
Extension::V010(ext) => {
|
||||
ext.call_run_slash_command(store, command, argument, resource)
|
||||
ext.call_run_slash_command(store, command, arguments, resource)
|
||||
.await
|
||||
}
|
||||
Extension::V001(_) | Extension::V004(_) | Extension::V006(_) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue