Allow an initial prompt to be associated with inline assist (#14816)
Release Notes: - Added the ability to create custom inline assist bindings that pre-fill a prompt from your keymap, e.g.: ```json [ { "context": "Editor && mode == full", "bindings": { "ctrl-shift-enter": [ "assistant::InlineAssist", { "prompt": "Build a snake game" } ] } } ] ``` --------- Co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
parent
d61eaea4b9
commit
4c7f1032a4
8 changed files with 52 additions and 54 deletions
|
@ -454,7 +454,7 @@ impl AssistantPanel {
|
|||
|
||||
pub fn inline_assist(
|
||||
workspace: &mut Workspace,
|
||||
_: &InlineAssist,
|
||||
action: &InlineAssist,
|
||||
cx: &mut ViewContext<Workspace>,
|
||||
) {
|
||||
let settings = AssistantSettings::get_global(cx);
|
||||
|
@ -472,6 +472,7 @@ impl AssistantPanel {
|
|||
return;
|
||||
};
|
||||
|
||||
let initial_prompt = action.prompt.clone();
|
||||
if assistant_panel.update(cx, |assistant, cx| assistant.is_authenticated(cx)) {
|
||||
match inline_assist_target {
|
||||
InlineAssistTarget::Editor(active_editor, include_context) => {
|
||||
|
@ -480,6 +481,7 @@ impl AssistantPanel {
|
|||
&active_editor,
|
||||
Some(cx.view().downgrade()),
|
||||
include_context.then_some(&assistant_panel),
|
||||
initial_prompt,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
|
@ -490,6 +492,7 @@ impl AssistantPanel {
|
|||
&active_terminal,
|
||||
Some(cx.view().downgrade()),
|
||||
Some(&assistant_panel),
|
||||
initial_prompt,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
|
@ -514,6 +517,7 @@ impl AssistantPanel {
|
|||
&active_editor,
|
||||
Some(workspace),
|
||||
assistant_panel.as_ref(),
|
||||
initial_prompt,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
|
@ -524,6 +528,7 @@ impl AssistantPanel {
|
|||
&active_terminal,
|
||||
Some(workspace),
|
||||
assistant_panel.upgrade().as_ref(),
|
||||
initial_prompt,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue