Run slash commands both on enter and on argument completion that requires it (#16283)

Release Notes:

- N/A
This commit is contained in:
Kirill Bulatov 2024-08-15 19:36:30 +03:00 committed by GitHub
parent 5a30e29848
commit c45adce2e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 61 additions and 34 deletions

View file

@ -39,6 +39,10 @@ impl SlashCommand for TabSlashCommand {
false
}
fn accepts_arguments(&self) -> bool {
true
}
fn complete_argument(
self: Arc<Self>,
arguments: &[String],
@ -94,15 +98,16 @@ impl SlashCommand for TabSlashCommand {
})
});
let active_item_completion = active_item_path.as_deref().map(|active_item_path| {
let path_string = active_item_path.to_string_lossy().to_string();
ArgumentCompletion {
let active_item_completion = active_item_path
.as_deref()
.map(|active_item_path| active_item_path.to_string_lossy().to_string())
.filter(|path_string| !argument_set.contains(path_string))
.map(|path_string| ArgumentCompletion {
label: path_string.clone().into(),
new_text: path_string,
replace_previous_arguments: false,
run_command,
}
});
});
Ok(active_item_completion
.into_iter()