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
|
@ -87,6 +87,7 @@ impl InlineAssistant {
|
|||
editor: &View<Editor>,
|
||||
workspace: Option<WeakView<Workspace>>,
|
||||
assistant_panel: Option<&View<AssistantPanel>>,
|
||||
initial_prompt: Option<String>,
|
||||
cx: &mut WindowContext,
|
||||
) {
|
||||
let snapshot = editor.read(cx).buffer().read(cx).snapshot(cx);
|
||||
|
@ -138,7 +139,8 @@ impl InlineAssistant {
|
|||
}
|
||||
|
||||
let assist_group_id = self.next_assist_group_id.post_inc();
|
||||
let prompt_buffer = cx.new_model(|cx| Buffer::local("", cx));
|
||||
let prompt_buffer =
|
||||
cx.new_model(|cx| Buffer::local(initial_prompt.unwrap_or_default(), cx));
|
||||
let prompt_buffer = cx.new_model(|cx| MultiBuffer::singleton(prompt_buffer, cx));
|
||||
|
||||
let mut assists = Vec::new();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue