Make slash commands more discoverable (#12480)
<img width="648" alt="image" src="https://github.com/zed-industries/zed/assets/482957/a63df904-fbbe-4e0a-80b2-c98ebee90690"> Release Notes: - N/A Co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
parent
436a8fa0ce
commit
a259042f92
16 changed files with 172 additions and 100 deletions
|
@ -18,9 +18,9 @@ use anyhow::{anyhow, Result};
|
||||||
use assistant_slash_command::{SlashCommandOutput, SlashCommandOutputSection};
|
use assistant_slash_command::{SlashCommandOutput, SlashCommandOutputSection};
|
||||||
use client::telemetry::Telemetry;
|
use client::telemetry::Telemetry;
|
||||||
use collections::{hash_map, BTreeSet, HashMap, HashSet, VecDeque};
|
use collections::{hash_map, BTreeSet, HashMap, HashSet, VecDeque};
|
||||||
use editor::actions::UnfoldAt;
|
use editor::actions::ShowCompletions;
|
||||||
use editor::{
|
use editor::{
|
||||||
actions::{FoldAt, MoveDown, MoveUp},
|
actions::{FoldAt, MoveDown, MoveToEndOfLine, MoveUp, Newline, UnfoldAt},
|
||||||
display_map::{
|
display_map::{
|
||||||
BlockContext, BlockDisposition, BlockId, BlockProperties, BlockStyle, Flap, ToDisplayPoint,
|
BlockContext, BlockDisposition, BlockId, BlockProperties, BlockStyle, Flap, ToDisplayPoint,
|
||||||
},
|
},
|
||||||
|
@ -212,15 +212,20 @@ impl AssistantPanel {
|
||||||
|
|
||||||
let slash_command_registry = SlashCommandRegistry::global(cx);
|
let slash_command_registry = SlashCommandRegistry::global(cx);
|
||||||
|
|
||||||
slash_command_registry.register_command(file_command::FileSlashCommand);
|
slash_command_registry.register_command(file_command::FileSlashCommand, true);
|
||||||
slash_command_registry.register_command(
|
slash_command_registry.register_command(
|
||||||
prompt_command::PromptSlashCommand::new(prompt_library.clone()),
|
prompt_command::PromptSlashCommand::new(prompt_library.clone()),
|
||||||
|
true,
|
||||||
);
|
);
|
||||||
slash_command_registry.register_command(active_command::ActiveSlashCommand);
|
slash_command_registry
|
||||||
slash_command_registry.register_command(tabs_command::TabsSlashCommand);
|
.register_command(active_command::ActiveSlashCommand, true);
|
||||||
slash_command_registry.register_command(project_command::ProjectSlashCommand);
|
slash_command_registry.register_command(tabs_command::TabsSlashCommand, true);
|
||||||
slash_command_registry.register_command(search_command::SearchSlashCommand);
|
slash_command_registry
|
||||||
slash_command_registry.register_command(rustdoc_command::RustdocSlashCommand);
|
.register_command(project_command::ProjectSlashCommand, true);
|
||||||
|
slash_command_registry
|
||||||
|
.register_command(search_command::SearchSlashCommand, true);
|
||||||
|
slash_command_registry
|
||||||
|
.register_command(rustdoc_command::RustdocSlashCommand, false);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
workspace: workspace_handle,
|
workspace: workspace_handle,
|
||||||
|
@ -943,6 +948,14 @@ impl AssistantPanel {
|
||||||
self.model_menu_handle.toggle(cx);
|
self.model_menu_handle.toggle(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn insert_command(&mut self, name: &str, cx: &mut ViewContext<Self>) {
|
||||||
|
if let Some(conversation_editor) = self.active_conversation_editor() {
|
||||||
|
conversation_editor.update(cx, |conversation_editor, cx| {
|
||||||
|
conversation_editor.insert_command(name, cx)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn active_conversation_editor(&self) -> Option<&View<ConversationEditor>> {
|
fn active_conversation_editor(&self) -> Option<&View<ConversationEditor>> {
|
||||||
Some(&self.active_conversation_editor.as_ref()?.editor)
|
Some(&self.active_conversation_editor.as_ref()?.editor)
|
||||||
}
|
}
|
||||||
|
@ -980,52 +993,65 @@ impl AssistantPanel {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_inject_context_menu(&self, _cx: &mut ViewContext<Self>) -> impl Element {
|
fn render_inject_context_menu(&self, cx: &mut ViewContext<Self>) -> impl Element {
|
||||||
let workspace = self.workspace.clone();
|
let commands = self.slash_commands.clone();
|
||||||
|
let assistant_panel = cx.view().downgrade();
|
||||||
|
let active_editor_focus_handle = self.workspace.upgrade().and_then(|workspace| {
|
||||||
|
Some(
|
||||||
|
workspace
|
||||||
|
.read(cx)
|
||||||
|
.active_item_as::<Editor>(cx)?
|
||||||
|
.focus_handle(cx),
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
popover_menu("inject-context-menu")
|
popover_menu("inject-context-menu")
|
||||||
.trigger(IconButton::new("trigger", IconName::Quote).tooltip(|cx| {
|
.trigger(IconButton::new("trigger", IconName::Quote).tooltip(|cx| {
|
||||||
// Tooltip::with_meta("Insert Context", None, "Type # to insert via keyboard", cx)
|
Tooltip::with_meta("Insert Context", None, "Type / to insert via keyboard", cx)
|
||||||
Tooltip::text("Insert Context", cx)
|
|
||||||
}))
|
}))
|
||||||
.menu(move |cx| {
|
.menu(move |cx| {
|
||||||
ContextMenu::build(cx, |menu, _cx| {
|
ContextMenu::build(cx, |mut menu, _cx| {
|
||||||
// menu.entry("Insert Search", None, {
|
for command_name in commands.featured_command_names() {
|
||||||
// let assistant = assistant.clone();
|
if let Some(command) = commands.command(&command_name) {
|
||||||
// move |_cx| {}
|
let menu_text = SharedString::from(Arc::from(command.menu_text()));
|
||||||
// })
|
menu = menu.custom_entry(
|
||||||
// .entry("Insert Docs", None, {
|
{
|
||||||
// let assistant = assistant.clone();
|
let command_name = command_name.clone();
|
||||||
// move |cx| {}
|
move |_cx| {
|
||||||
// })
|
h_flex()
|
||||||
menu.entry("Quote Selection", None, {
|
.w_full()
|
||||||
let workspace = workspace.clone();
|
.justify_between()
|
||||||
move |cx| {
|
.child(Label::new(menu_text.clone()))
|
||||||
workspace
|
.child(
|
||||||
.update(cx, |workspace, cx| {
|
div().ml_4().child(
|
||||||
ConversationEditor::quote_selection(
|
Label::new(format!("/{command_name}"))
|
||||||
workspace,
|
.color(Color::Muted),
|
||||||
&Default::default(),
|
),
|
||||||
cx,
|
)
|
||||||
)
|
.into_any()
|
||||||
})
|
}
|
||||||
.ok();
|
},
|
||||||
|
{
|
||||||
|
let assistant_panel = assistant_panel.clone();
|
||||||
|
move |cx| {
|
||||||
|
assistant_panel
|
||||||
|
.update(cx, |assistant_panel, cx| {
|
||||||
|
assistant_panel.insert_command(&command_name, cx)
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
// .entry("Insert Active Prompt", None, {
|
|
||||||
// let workspace = workspace.clone();
|
if let Some(active_editor_focus_handle) = active_editor_focus_handle.clone() {
|
||||||
// move |cx| {
|
menu = menu
|
||||||
// workspace
|
.context(active_editor_focus_handle)
|
||||||
// .update(cx, |workspace, cx| {
|
.action("Quote Selection", Box::new(QuoteSelection));
|
||||||
// ConversationEditor::insert_active_prompt(
|
}
|
||||||
// workspace,
|
|
||||||
// &Default::default(),
|
menu
|
||||||
// cx,
|
|
||||||
// )
|
|
||||||
// })
|
|
||||||
// .ok();
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
})
|
})
|
||||||
.into()
|
.into()
|
||||||
})
|
})
|
||||||
|
@ -1720,7 +1746,6 @@ impl Conversation {
|
||||||
let pending_command = PendingSlashCommand {
|
let pending_command = PendingSlashCommand {
|
||||||
name: name.to_string(),
|
name: name.to_string(),
|
||||||
argument: argument.map(ToString::to_string),
|
argument: argument.map(ToString::to_string),
|
||||||
tooltip_text: command.tooltip_text().into(),
|
|
||||||
source_range,
|
source_range,
|
||||||
status: PendingSlashCommandStatus::Idle,
|
status: PendingSlashCommandStatus::Idle,
|
||||||
};
|
};
|
||||||
|
@ -2517,7 +2542,6 @@ struct PendingSlashCommand {
|
||||||
argument: Option<String>,
|
argument: Option<String>,
|
||||||
status: PendingSlashCommandStatus,
|
status: PendingSlashCommandStatus,
|
||||||
source_range: Range<language::Anchor>,
|
source_range: Range<language::Anchor>,
|
||||||
tooltip_text: SharedString,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -2690,11 +2714,47 @@ impl ConversationEditor {
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn insert_command(&mut self, name: &str, cx: &mut ViewContext<Self>) {
|
||||||
|
if let Some(command) = self.slash_command_registry.command(name) {
|
||||||
|
self.editor.update(cx, |editor, cx| {
|
||||||
|
editor.transact(cx, |editor, cx| {
|
||||||
|
editor.change_selections(Some(Autoscroll::fit()), cx, |s| s.try_cancel());
|
||||||
|
let snapshot = editor.buffer().read(cx).snapshot(cx);
|
||||||
|
let newest_cursor = editor.selections.newest::<Point>(cx).head();
|
||||||
|
if newest_cursor.column > 0
|
||||||
|
|| snapshot
|
||||||
|
.chars_at(newest_cursor)
|
||||||
|
.next()
|
||||||
|
.map_or(false, |ch| ch != '\n')
|
||||||
|
{
|
||||||
|
editor.move_to_end_of_line(
|
||||||
|
&MoveToEndOfLine {
|
||||||
|
stop_at_soft_wraps: false,
|
||||||
|
},
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
editor.newline(&Newline, cx);
|
||||||
|
}
|
||||||
|
|
||||||
|
editor.insert(&format!("/{name}"), cx);
|
||||||
|
if command.requires_argument() {
|
||||||
|
editor.insert(" ", cx);
|
||||||
|
editor.show_completions(&ShowCompletions, cx);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
if !command.requires_argument() {
|
||||||
|
self.confirm_command(&ConfirmCommand, cx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn confirm_command(&mut self, _: &ConfirmCommand, cx: &mut ViewContext<Self>) {
|
pub fn confirm_command(&mut self, _: &ConfirmCommand, cx: &mut ViewContext<Self>) {
|
||||||
let selections = self.editor.read(cx).selections.disjoint_anchors();
|
let selections = self.editor.read(cx).selections.disjoint_anchors();
|
||||||
let mut commands_by_range = HashMap::default();
|
let mut commands_by_range = HashMap::default();
|
||||||
let workspace = self.workspace.clone();
|
let workspace = self.workspace.clone();
|
||||||
self.conversation.update(cx, |conversation, cx| {
|
self.conversation.update(cx, |conversation, cx| {
|
||||||
|
conversation.reparse_slash_commands(cx);
|
||||||
for selection in selections.iter() {
|
for selection in selections.iter() {
|
||||||
if let Some(command) =
|
if let Some(command) =
|
||||||
conversation.pending_command_for_position(selection.head().text_anchor, cx)
|
conversation.pending_command_for_position(selection.head().text_anchor, cx)
|
||||||
|
@ -2851,9 +2911,8 @@ impl ConversationEditor {
|
||||||
let confirm_command = confirm_command.clone();
|
let confirm_command = confirm_command.clone();
|
||||||
let command = command.clone();
|
let command = command.clone();
|
||||||
move |row, _, _, _cx: &mut WindowContext| {
|
move |row, _, _, _cx: &mut WindowContext| {
|
||||||
render_pending_slash_command_toggle(
|
render_pending_slash_command_gutter_decoration(
|
||||||
row,
|
row,
|
||||||
command.tooltip_text.clone(),
|
|
||||||
command.status.clone(),
|
command.status.clone(),
|
||||||
confirm_command.clone(),
|
confirm_command.clone(),
|
||||||
)
|
)
|
||||||
|
@ -3680,14 +3739,13 @@ fn render_slash_command_output_toggle(
|
||||||
.into_any_element()
|
.into_any_element()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_pending_slash_command_toggle(
|
fn render_pending_slash_command_gutter_decoration(
|
||||||
row: MultiBufferRow,
|
row: MultiBufferRow,
|
||||||
tooltip_text: SharedString,
|
|
||||||
status: PendingSlashCommandStatus,
|
status: PendingSlashCommandStatus,
|
||||||
confirm_command: Arc<dyn Fn(&mut WindowContext)>,
|
confirm_command: Arc<dyn Fn(&mut WindowContext)>,
|
||||||
) -> AnyElement {
|
) -> AnyElement {
|
||||||
let mut icon = IconButton::new(
|
let mut icon = IconButton::new(
|
||||||
("slash-command-output-fold-indicator", row.0),
|
("slash-command-gutter-decoration", row.0),
|
||||||
ui::IconName::TriangleRight,
|
ui::IconName::TriangleRight,
|
||||||
)
|
)
|
||||||
.on_click(move |_e, cx| confirm_command(cx))
|
.on_click(move |_e, cx| confirm_command(cx))
|
||||||
|
@ -3696,14 +3754,10 @@ fn render_pending_slash_command_toggle(
|
||||||
|
|
||||||
match status {
|
match status {
|
||||||
PendingSlashCommandStatus::Idle => {
|
PendingSlashCommandStatus::Idle => {
|
||||||
icon = icon
|
icon = icon.icon_color(Color::Muted);
|
||||||
.icon_color(Color::Muted)
|
|
||||||
.tooltip(move |cx| Tooltip::text(tooltip_text.clone(), cx));
|
|
||||||
}
|
}
|
||||||
PendingSlashCommandStatus::Running { .. } => {
|
PendingSlashCommandStatus::Running { .. } => {
|
||||||
icon = icon
|
icon = icon.selected(true);
|
||||||
.selected(true)
|
|
||||||
.tooltip(move |cx| Tooltip::text(tooltip_text.clone(), cx));
|
|
||||||
}
|
}
|
||||||
PendingSlashCommandStatus::Error(error) => {
|
PendingSlashCommandStatus::Error(error) => {
|
||||||
icon = icon
|
icon = icon
|
||||||
|
@ -4126,10 +4180,11 @@ mod tests {
|
||||||
let prompt_library = Arc::new(PromptLibrary::default());
|
let prompt_library = Arc::new(PromptLibrary::default());
|
||||||
let slash_command_registry = SlashCommandRegistry::new();
|
let slash_command_registry = SlashCommandRegistry::new();
|
||||||
|
|
||||||
slash_command_registry.register_command(file_command::FileSlashCommand);
|
slash_command_registry.register_command(file_command::FileSlashCommand, false);
|
||||||
slash_command_registry.register_command(prompt_command::PromptSlashCommand::new(
|
slash_command_registry.register_command(
|
||||||
prompt_library.clone(),
|
prompt_command::PromptSlashCommand::new(prompt_library.clone()),
|
||||||
));
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
let registry = Arc::new(LanguageRegistry::test(cx.executor()));
|
let registry = Arc::new(LanguageRegistry::test(cx.executor()));
|
||||||
let conversation = cx
|
let conversation = cx
|
||||||
|
|
|
@ -19,8 +19,8 @@ impl SlashCommand for ActiveSlashCommand {
|
||||||
"insert active tab".into()
|
"insert active tab".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tooltip_text(&self) -> String {
|
fn menu_text(&self) -> String {
|
||||||
"insert active tab".into()
|
"Insert Active Tab".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn complete_argument(
|
fn complete_argument(
|
||||||
|
|
|
@ -86,11 +86,11 @@ impl SlashCommand for FileSlashCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn description(&self) -> String {
|
fn description(&self) -> String {
|
||||||
"insert a file".into()
|
"insert file".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tooltip_text(&self) -> String {
|
fn menu_text(&self) -> String {
|
||||||
"insert file".into()
|
"Insert File".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn requires_argument(&self) -> bool {
|
fn requires_argument(&self) -> bool {
|
||||||
|
|
|
@ -94,11 +94,11 @@ impl SlashCommand for ProjectSlashCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn description(&self) -> String {
|
fn description(&self) -> String {
|
||||||
"insert current project context".into()
|
"insert project metadata".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tooltip_text(&self) -> String {
|
fn menu_text(&self) -> String {
|
||||||
"insert current project context".into()
|
"Insert Project Metadata".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn complete_argument(
|
fn complete_argument(
|
||||||
|
|
|
@ -25,11 +25,11 @@ impl SlashCommand for PromptSlashCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn description(&self) -> String {
|
fn description(&self) -> String {
|
||||||
"insert a prompt from the library".into()
|
"insert prompt from library".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tooltip_text(&self) -> String {
|
fn menu_text(&self) -> String {
|
||||||
"insert prompt".into()
|
"Insert Prompt from Library".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn requires_argument(&self) -> bool {
|
fn requires_argument(&self) -> bool {
|
||||||
|
|
|
@ -51,11 +51,11 @@ impl SlashCommand for RustdocSlashCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn description(&self) -> String {
|
fn description(&self) -> String {
|
||||||
"insert the docs for a Rust crate".into()
|
"insert Rust docs".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tooltip_text(&self) -> String {
|
fn menu_text(&self) -> String {
|
||||||
"insert rustdoc".into()
|
"Insert Rust Documentation".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn requires_argument(&self) -> bool {
|
fn requires_argument(&self) -> bool {
|
||||||
|
|
|
@ -32,11 +32,11 @@ impl SlashCommand for SearchSlashCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn description(&self) -> String {
|
fn description(&self) -> String {
|
||||||
"semantically search files".into()
|
"semantic search".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tooltip_text(&self) -> String {
|
fn menu_text(&self) -> String {
|
||||||
"search".into()
|
"Semantic Search".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn requires_argument(&self) -> bool {
|
fn requires_argument(&self) -> bool {
|
||||||
|
|
|
@ -17,11 +17,11 @@ impl SlashCommand for TabsSlashCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn description(&self) -> String {
|
fn description(&self) -> String {
|
||||||
"insert content from open tabs".into()
|
"insert open tabs".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tooltip_text(&self) -> String {
|
fn menu_text(&self) -> String {
|
||||||
"insert open tabs".into()
|
"Insert Open Tabs".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn requires_argument(&self) -> bool {
|
fn requires_argument(&self) -> bool {
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub trait SlashCommand: 'static + Send + Sync {
|
||||||
CodeLabel::plain(self.name(), None)
|
CodeLabel::plain(self.name(), None)
|
||||||
}
|
}
|
||||||
fn description(&self) -> String;
|
fn description(&self) -> String;
|
||||||
fn tooltip_text(&self) -> String;
|
fn menu_text(&self) -> String;
|
||||||
fn complete_argument(
|
fn complete_argument(
|
||||||
&self,
|
&self,
|
||||||
query: String,
|
query: String,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use collections::HashMap;
|
use collections::{BTreeSet, HashMap};
|
||||||
use derive_more::{Deref, DerefMut};
|
use derive_more::{Deref, DerefMut};
|
||||||
use gpui::Global;
|
use gpui::Global;
|
||||||
use gpui::{AppContext, ReadGlobal};
|
use gpui::{AppContext, ReadGlobal};
|
||||||
|
@ -16,6 +16,7 @@ impl Global for GlobalSlashCommandRegistry {}
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct SlashCommandRegistryState {
|
struct SlashCommandRegistryState {
|
||||||
commands: HashMap<Arc<str>, Arc<dyn SlashCommand>>,
|
commands: HashMap<Arc<str>, Arc<dyn SlashCommand>>,
|
||||||
|
featured_commands: BTreeSet<Arc<str>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
@ -40,16 +41,19 @@ impl SlashCommandRegistry {
|
||||||
Arc::new(Self {
|
Arc::new(Self {
|
||||||
state: RwLock::new(SlashCommandRegistryState {
|
state: RwLock::new(SlashCommandRegistryState {
|
||||||
commands: HashMap::default(),
|
commands: HashMap::default(),
|
||||||
|
featured_commands: BTreeSet::default(),
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Registers the provided [`SlashCommand`].
|
/// Registers the provided [`SlashCommand`].
|
||||||
pub fn register_command(&self, command: impl SlashCommand) {
|
pub fn register_command(&self, command: impl SlashCommand, is_featured: bool) {
|
||||||
self.state
|
let mut state = self.state.write();
|
||||||
.write()
|
let command_name: Arc<str> = command.name().into();
|
||||||
.commands
|
if is_featured {
|
||||||
.insert(command.name().into(), Arc::new(command));
|
state.featured_commands.insert(command_name.clone());
|
||||||
|
}
|
||||||
|
state.commands.insert(command_name, Arc::new(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the names of registered [`SlashCommand`]s.
|
/// Returns the names of registered [`SlashCommand`]s.
|
||||||
|
@ -57,6 +61,16 @@ impl SlashCommandRegistry {
|
||||||
self.state.read().commands.keys().cloned().collect()
|
self.state.read().commands.keys().cloned().collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the names of registered, featured [`SlashCommand`]s.
|
||||||
|
pub fn featured_command_names(&self) -> Vec<Arc<str>> {
|
||||||
|
self.state
|
||||||
|
.read()
|
||||||
|
.featured_commands
|
||||||
|
.iter()
|
||||||
|
.cloned()
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the [`SlashCommand`] with the given name.
|
/// Returns the [`SlashCommand`] with the given name.
|
||||||
pub fn command(&self, name: &str) -> Option<Arc<dyn SlashCommand>> {
|
pub fn command(&self, name: &str) -> Option<Arc<dyn SlashCommand>> {
|
||||||
self.state.read().commands.get(name).cloned()
|
self.state.read().commands.get(name).cloned()
|
||||||
|
|
|
@ -41,7 +41,7 @@ pub struct MovePageDown {
|
||||||
#[derive(PartialEq, Clone, Deserialize, Default)]
|
#[derive(PartialEq, Clone, Deserialize, Default)]
|
||||||
pub struct MoveToEndOfLine {
|
pub struct MoveToEndOfLine {
|
||||||
#[serde(default = "default_true")]
|
#[serde(default = "default_true")]
|
||||||
pub(super) stop_at_soft_wraps: bool,
|
pub stop_at_soft_wraps: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Deserialize, Default)]
|
#[derive(PartialEq, Clone, Deserialize, Default)]
|
||||||
|
|
|
@ -3761,7 +3761,7 @@ impl Editor {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn show_completions(&mut self, _: &ShowCompletions, cx: &mut ViewContext<Self>) {
|
pub fn show_completions(&mut self, _: &ShowCompletions, cx: &mut ViewContext<Self>) {
|
||||||
if self.pending_rename.is_some() {
|
if self.pending_rename.is_some() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ impl SlashCommand for ExtensionSlashCommand {
|
||||||
self.command.description.clone()
|
self.command.description.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tooltip_text(&self) -> String {
|
fn menu_text(&self) -> String {
|
||||||
self.command.tooltip_text.clone()
|
self.command.tooltip_text.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1178,8 +1178,8 @@ impl ExtensionStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (slash_command_name, slash_command) in &manifest.slash_commands {
|
for (slash_command_name, slash_command) in &manifest.slash_commands {
|
||||||
this.slash_command_registry
|
this.slash_command_registry.register_command(
|
||||||
.register_command(ExtensionSlashCommand {
|
ExtensionSlashCommand {
|
||||||
command: crate::wit::SlashCommand {
|
command: crate::wit::SlashCommand {
|
||||||
name: slash_command_name.to_string(),
|
name: slash_command_name.to_string(),
|
||||||
description: slash_command.description.to_string(),
|
description: slash_command.description.to_string(),
|
||||||
|
@ -1188,7 +1188,9 @@ impl ExtensionStore {
|
||||||
},
|
},
|
||||||
extension: wasm_extension.clone(),
|
extension: wasm_extension.clone(),
|
||||||
host: this.wasm_host.clone(),
|
host: this.wasm_host.clone(),
|
||||||
});
|
},
|
||||||
|
false,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.wasm_extensions.extend(wasm_extensions);
|
this.wasm_extensions.extend(wasm_extensions);
|
||||||
|
|
|
@ -357,7 +357,7 @@ impl Render for ContextMenu {
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
KeyBinding::for_action(&**action, cx)
|
KeyBinding::for_action(&**action, cx)
|
||||||
})
|
})
|
||||||
.map(|binding| div().ml_1().child(binding))
|
.map(|binding| div().ml_4().child(binding))
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
.on_click(move |_, cx| {
|
.on_click(move |_, cx| {
|
||||||
|
|
|
@ -77,13 +77,14 @@ impl RenderOnce for KeyBinding {
|
||||||
.join(" ")
|
.join(" ")
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
.gap(rems(0.125))
|
||||||
.flex_none()
|
.flex_none()
|
||||||
.children(self.key_binding.keystrokes().iter().map(|keystroke| {
|
.children(self.key_binding.keystrokes().iter().map(|keystroke| {
|
||||||
let key_icon = Self::icon_for_key(keystroke);
|
let key_icon = Self::icon_for_key(keystroke);
|
||||||
|
|
||||||
h_flex()
|
h_flex()
|
||||||
.flex_none()
|
.flex_none()
|
||||||
.p_0p5()
|
.py_0p5()
|
||||||
.rounded_sm()
|
.rounded_sm()
|
||||||
.text_color(cx.theme().colors().text_muted)
|
.text_color(cx.theme().colors().text_muted)
|
||||||
.when(keystroke.modifiers.function, |el| {
|
.when(keystroke.modifiers.function, |el| {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue