Do not pass text size to Preedit::new

This commit is contained in:
rhysd 2025-02-06 09:57:01 +09:00
parent fcdf53afde
commit cf851e133a
3 changed files with 12 additions and 8 deletions

View file

@ -40,14 +40,11 @@ pub struct Preedit<T = String> {
impl<T> Preedit<T> {
/// Creates a new empty [`Preedit`].
pub fn new(text_size: Option<impl Into<Pixels>>) -> Self
pub fn new() -> Self
where
T: Default,
{
Self {
text_size: text_size.map(Into::into),
..Default::default()
}
Self::default()
}
/// Turns a [`Preedit`] into its owned version.

View file

@ -754,7 +754,9 @@ where
Update::InputMethod(update) => match update {
Ime::Toggle(is_open) => {
state.preedit = is_open.then(|| {
input_method::Preedit::new(self.text_size)
let mut preedit = input_method::Preedit::new();
preedit.text_size = self.text_size;
preedit
});
shell.request_redraw();

View file

@ -1261,8 +1261,13 @@ where
let state = state::<Renderer>(tree);
state.is_ime_open =
matches!(event, input_method::Event::Opened)
.then(|| input_method::Preedit::new(self.size));
matches!(event, input_method::Event::Opened).then(
|| {
let mut preedit = input_method::Preedit::new();
preedit.text_size = self.size;
preedit
},
);
shell.request_redraw();
}