Add hidden prompt_to_focus field to OpenPromptLibrary action (#29062)

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-04-18 14:39:40 -06:00 committed by GitHub
parent 327fee4d22
commit 73a767fc45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 60 additions and 18 deletions

View file

@ -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
})
},
)