Adjust design of the slash command picker (#19973)

This PR removes the quote selection icon button from the footer and adds
it in the picker, and adds an icon field to each command entry. Final
result looks like:


https://github.com/user-attachments/assets/d177f1c1-b6f6-4652-9434-f6291b279e34

Release Notes:

- N/A
This commit is contained in:
Danilo Leal 2024-10-30 19:42:42 -03:00 committed by GitHub
parent f80eb264fb
commit 6d5784daa6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 185 additions and 110 deletions

View file

@ -73,12 +73,11 @@ use std::{
};
use terminal_view::{terminal_panel::TerminalPanel, TerminalView};
use text::SelectionGoal;
use ui::TintColor;
use ui::{
prelude::*,
utils::{format_distance_from_now, DateTimeType},
Avatar, ButtonLike, ContextMenu, Disclosure, ElevationIndex, KeyBinding, ListItem,
ListItemSpacing, PopoverMenu, PopoverMenuHandle, Tooltip,
ListItemSpacing, PopoverMenu, PopoverMenuHandle, TintColor, Tooltip,
};
use util::{maybe, ResultExt};
use workspace::{
@ -4006,13 +4005,7 @@ impl Render for ContextEditor {
} else {
None
};
let focus_handle = self
.workspace
.update(cx, |workspace, cx| {
Some(workspace.active_item_as::<Editor>(cx)?.focus_handle(cx))
})
.ok()
.flatten();
v_flex()
.key_context("ContextEditor")
.capture_action(cx.listener(ContextEditor::cancel))
@ -4060,28 +4053,7 @@ impl Render for ContextEditor {
.child(
h_flex()
.gap_1()
.child(render_inject_context_menu(cx.view().downgrade(), cx))
.child(
IconButton::new("quote-button", IconName::Quote)
.icon_size(IconSize::Small)
.on_click(|_, cx| {
cx.dispatch_action(QuoteSelection.boxed_clone());
})
.tooltip(move |cx| {
cx.new_view(|cx| {
Tooltip::new("Insert Selection").key_binding(
focus_handle.as_ref().and_then(|handle| {
KeyBinding::for_action_in(
&QuoteSelection,
&handle,
cx,
)
}),
)
})
.into()
}),
),
.child(render_inject_context_menu(cx.view().downgrade(), cx)),
)
.child(
h_flex()
@ -4376,6 +4348,7 @@ fn render_inject_context_menu(
Button::new("trigger", "Add Context")
.icon(IconName::Plus)
.icon_size(IconSize::Small)
.icon_color(Color::Muted)
.icon_position(IconPosition::Start)
.tooltip(|cx| Tooltip::text("Type / to insert via keyboard", cx)),
)
@ -4550,7 +4523,7 @@ impl Render for ContextEditorToolbarItem {
.w_full()
.justify_between()
.gap_2()
.child(Label::new("Insert Context"))
.child(Label::new("Add Context"))
.child(Label::new("/ command").color(Color::Muted))
.into_any()
},
@ -4574,7 +4547,7 @@ impl Render for ContextEditorToolbarItem {
}
},
)
.action("Insert Selection", QuoteSelection.boxed_clone())
.action("Add Selection", QuoteSelection.boxed_clone())
}))
}
}),