mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-07 20:39:04 +03:00
Show icon to toggle inline assist
This commit is contained in:
parent
d804afcfa9
commit
1fb7ce0f4a
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -5647,6 +5647,7 @@ dependencies = [
|
||||
name = "quick_action_bar"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"ai",
|
||||
"editor",
|
||||
"gpui",
|
||||
"search",
|
||||
|
@ -215,7 +215,11 @@ impl AssistantPanel {
|
||||
})
|
||||
}
|
||||
|
||||
fn inline_assist(workspace: &mut Workspace, _: &InlineAssist, cx: &mut ViewContext<Workspace>) {
|
||||
pub fn inline_assist(
|
||||
workspace: &mut Workspace,
|
||||
_: &InlineAssist,
|
||||
cx: &mut ViewContext<Workspace>,
|
||||
) {
|
||||
let this = if let Some(this) = workspace.panel::<AssistantPanel>(cx) {
|
||||
if this
|
||||
.update(cx, |assistant, cx| assistant.load_api_key(cx))
|
||||
|
@ -9,6 +9,7 @@ path = "src/quick_action_bar.rs"
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
ai = { path = "../ai" }
|
||||
editor = { path = "../editor" }
|
||||
gpui = { path = "../gpui" }
|
||||
search = { path = "../search" }
|
||||
|
@ -1,25 +1,29 @@
|
||||
use ai::{assistant::InlineAssist, AssistantPanel};
|
||||
use editor::Editor;
|
||||
use gpui::{
|
||||
elements::{Empty, Flex, MouseEventHandler, ParentElement, Svg},
|
||||
platform::{CursorStyle, MouseButton},
|
||||
Action, AnyElement, Element, Entity, EventContext, Subscription, View, ViewContext, ViewHandle,
|
||||
WeakViewHandle,
|
||||
};
|
||||
|
||||
use search::{buffer_search, BufferSearchBar};
|
||||
use workspace::{item::ItemHandle, ToolbarItemLocation, ToolbarItemView};
|
||||
use workspace::{item::ItemHandle, ToolbarItemLocation, ToolbarItemView, Workspace};
|
||||
|
||||
pub struct QuickActionBar {
|
||||
buffer_search_bar: ViewHandle<BufferSearchBar>,
|
||||
active_item: Option<Box<dyn ItemHandle>>,
|
||||
_inlay_hints_enabled_subscription: Option<Subscription>,
|
||||
workspace: WeakViewHandle<Workspace>,
|
||||
}
|
||||
|
||||
impl QuickActionBar {
|
||||
pub fn new(buffer_search_bar: ViewHandle<BufferSearchBar>) -> Self {
|
||||
pub fn new(buffer_search_bar: ViewHandle<BufferSearchBar>, workspace: &Workspace) -> Self {
|
||||
Self {
|
||||
buffer_search_bar,
|
||||
active_item: None,
|
||||
_inlay_hints_enabled_subscription: None,
|
||||
workspace: workspace.weak_handle(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,6 +90,21 @@ impl View for QuickActionBar {
|
||||
));
|
||||
}
|
||||
|
||||
bar.add_child(render_quick_action_bar_button(
|
||||
2,
|
||||
"icons/radix/magic-wand.svg",
|
||||
false,
|
||||
("Generate code...".into(), Some(Box::new(InlineAssist))),
|
||||
cx,
|
||||
move |this, cx| {
|
||||
if let Some(workspace) = this.workspace.upgrade(cx) {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
AssistantPanel::inline_assist(workspace, &Default::default(), cx);
|
||||
});
|
||||
}
|
||||
},
|
||||
));
|
||||
|
||||
bar.into_any()
|
||||
}
|
||||
}
|
||||
|
@ -264,8 +264,9 @@ pub fn initialize_workspace(
|
||||
toolbar.add_item(breadcrumbs, cx);
|
||||
let buffer_search_bar = cx.add_view(BufferSearchBar::new);
|
||||
toolbar.add_item(buffer_search_bar.clone(), cx);
|
||||
let quick_action_bar =
|
||||
cx.add_view(|_| QuickActionBar::new(buffer_search_bar));
|
||||
let quick_action_bar = cx.add_view(|_| {
|
||||
QuickActionBar::new(buffer_search_bar, workspace)
|
||||
});
|
||||
toolbar.add_item(quick_action_bar, cx);
|
||||
let project_search_bar = cx.add_view(|_| ProjectSearchBar::new());
|
||||
toolbar.add_item(project_search_bar, cx);
|
||||
|
Loading…
Reference in New Issue
Block a user