Add hidden prompt_to_focus
field to OpenPromptLibrary
action (#29062)
Release Notes: - N/A
This commit is contained in:
parent
327fee4d22
commit
73a767fc45
10 changed files with 60 additions and 18 deletions
|
@ -75,6 +75,7 @@ pub fn open_prompt_library(
|
|||
language_registry: Arc<LanguageRegistry>,
|
||||
inline_assist_delegate: Box<dyn InlineAssistDelegate>,
|
||||
make_completion_provider: Arc<dyn Fn() -> Box<dyn CompletionProvider>>,
|
||||
prompt_to_focus: Option<PromptId>,
|
||||
cx: &mut App,
|
||||
) -> Task<Result<WindowHandle<PromptLibrary>>> {
|
||||
let store = PromptStore::global(cx);
|
||||
|
@ -88,7 +89,12 @@ pub fn open_prompt_library(
|
|||
.find_map(|window| window.downcast::<PromptLibrary>());
|
||||
if let Some(existing_window) = existing_window {
|
||||
existing_window
|
||||
.update(cx, |_, window, _| window.activate_window())
|
||||
.update(cx, |prompt_library, window, cx| {
|
||||
if let Some(prompt_to_focus) = prompt_to_focus {
|
||||
prompt_library.load_prompt(prompt_to_focus, true, window, cx);
|
||||
}
|
||||
window.activate_window()
|
||||
})
|
||||
.ok();
|
||||
|
||||
Some(existing_window)
|
||||
|
@ -120,14 +126,18 @@ pub fn open_prompt_library(
|
|||
},
|
||||
|window, cx| {
|
||||
cx.new(|cx| {
|
||||
PromptLibrary::new(
|
||||
let mut prompt_library = PromptLibrary::new(
|
||||
store,
|
||||
language_registry,
|
||||
inline_assist_delegate,
|
||||
make_completion_provider,
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
);
|
||||
if let Some(prompt_to_focus) = prompt_to_focus {
|
||||
prompt_library.load_prompt(prompt_to_focus, true, window, cx);
|
||||
}
|
||||
prompt_library
|
||||
})
|
||||
},
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue