input: Fix Input to prepare text wrapper. (#1417)
To ensure call update_all in TextWrapper.
This commit is contained in:
parent
804a89df20
commit
b42a429fdc
2 changed files with 12 additions and 0 deletions
|
|
@ -247,6 +247,7 @@ impl RenderOnce for TextInput {
|
||||||
|
|
||||||
self.state.update(cx, |state, cx| {
|
self.state.update(cx, |state, cx| {
|
||||||
state.text_wrapper.set_font(font, font_size, cx);
|
state.text_wrapper.set_font(font, font_size, cx);
|
||||||
|
state.text_wrapper.prepare_if_need(&state.text, cx);
|
||||||
state.disabled = self.disabled;
|
state.disabled = self.disabled;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,8 @@ pub(super) struct TextWrapper {
|
||||||
pub(super) longest_row: LongestRow,
|
pub(super) longest_row: LongestRow,
|
||||||
/// The lines by split \n
|
/// The lines by split \n
|
||||||
pub(super) lines: Vec<LineItem>,
|
pub(super) lines: Vec<LineItem>,
|
||||||
|
|
||||||
|
_initialized: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
|
|
@ -72,6 +74,7 @@ impl TextWrapper {
|
||||||
soft_lines: 0,
|
soft_lines: 0,
|
||||||
longest_row: LongestRow::default(),
|
longest_row: LongestRow::default(),
|
||||||
lines: Vec::new(),
|
lines: Vec::new(),
|
||||||
|
_initialized: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -111,6 +114,14 @@ impl TextWrapper {
|
||||||
self.update_all(&self.text.clone(), cx);
|
self.update_all(&self.text.clone(), cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(super) fn prepare_if_need(&mut self, text: &Rope, cx: &mut App) {
|
||||||
|
if self._initialized {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self._initialized = true;
|
||||||
|
self.update_all(text, cx);
|
||||||
|
}
|
||||||
|
|
||||||
/// Update the text wrapper and recalculate the wrapped lines.
|
/// Update the text wrapper and recalculate the wrapped lines.
|
||||||
///
|
///
|
||||||
/// If the `text` is the same as the current text, do nothing.
|
/// If the `text` is the same as the current text, do nothing.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue