assistant: Initialize the UI font in the prompt library window (#12701)

This PR fixes an issue where the prompt library did not properly have
the UI font or rem size set.

Since it is being opened in a new window, we need to re-initialize these
values the same way we do in the main window.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-06-05 17:41:03 -04:00 committed by GitHub
parent 9824e40878
commit 29d29f5a90
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -23,12 +23,14 @@ use parking_lot::RwLock;
use picker::{Picker, PickerDelegate}; use picker::{Picker, PickerDelegate};
use rope::Rope; use rope::Rope;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use settings::Settings;
use std::{ use std::{
future::Future, future::Future,
path::PathBuf, path::PathBuf,
sync::{atomic::AtomicBool, Arc}, sync::{atomic::AtomicBool, Arc},
time::Duration, time::Duration,
}; };
use theme::ThemeSettings;
use ui::{ use ui::{
div, prelude::*, IconButtonShape, ListHeader, ListItem, ListItemSpacing, ListSubHeader, div, prelude::*, IconButtonShape, ListHeader, ListItem, ListItemSpacing, ListSubHeader,
ParentElement, Render, SharedString, Styled, TitleBar, Tooltip, ViewContext, VisualContext, ParentElement, Render, SharedString, Styled, TitleBar, Tooltip, ViewContext, VisualContext,
@ -848,6 +850,14 @@ impl PromptLibrary {
impl Render for PromptLibrary { impl Render for PromptLibrary {
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement { fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
let (ui_font, ui_font_size) = {
let theme_settings = ThemeSettings::get_global(cx);
(theme_settings.ui_font.clone(), theme_settings.ui_font_size)
};
let theme = cx.theme().clone();
cx.set_rem_size(ui_font_size);
h_flex() h_flex()
.id("prompt-manager") .id("prompt-manager")
.key_context("PromptLibrary") .key_context("PromptLibrary")
@ -858,6 +868,8 @@ impl Render for PromptLibrary {
})) }))
.size_full() .size_full()
.overflow_hidden() .overflow_hidden()
.font(ui_font)
.text_color(theme.colors().text)
.child(self.render_prompt_list(cx)) .child(self.render_prompt_list(cx))
.child(self.render_active_prompt(cx)) .child(self.render_active_prompt(cx))
} }