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
|
@ -628,7 +628,7 @@ impl PromptLibrary {
|
|||
self.picker.update(cx, |picker, cx| picker.focus(cx));
|
||||
}
|
||||
|
||||
pub fn inline_assist(&mut self, _: &InlineAssist, cx: &mut ViewContext<Self>) {
|
||||
pub fn inline_assist(&mut self, action: &InlineAssist, cx: &mut ViewContext<Self>) {
|
||||
let Some(active_prompt_id) = self.active_prompt_id else {
|
||||
cx.propagate();
|
||||
return;
|
||||
|
@ -636,9 +636,10 @@ impl PromptLibrary {
|
|||
|
||||
let prompt_editor = &self.prompt_editors[&active_prompt_id].body_editor;
|
||||
let provider = CompletionProvider::global(cx);
|
||||
let initial_prompt = action.prompt.clone();
|
||||
if provider.is_authenticated() {
|
||||
InlineAssistant::update_global(cx, |assistant, cx| {
|
||||
assistant.assist(&prompt_editor, None, None, cx)
|
||||
assistant.assist(&prompt_editor, None, None, initial_prompt, cx)
|
||||
})
|
||||
} else {
|
||||
for window in cx.windows() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue