prevent panic on set_width_request when the parent widget yet not rendered

This commit is contained in:
yggverse 2026-04-02 19:04:03 +03:00
parent 8e6dc4b4dc
commit 0b8960c60c

View file

@ -9,6 +9,7 @@ const REGEX_HR: &str = r"(?m)^(?P<hr>\\?[-]{3,})$";
/// Apply --- `Tag` to given `TextBuffer` /// Apply --- `Tag` to given `TextBuffer`
pub fn render(text_view: &TextView) { pub fn render(text_view: &TextView) {
const OFFSET: i32 = 18;
let separator = Separator::builder() let separator = Separator::builder()
.orientation(Orientation::Horizontal) .orientation(Orientation::Horizontal)
.build(); .build();
@ -16,10 +17,15 @@ pub fn render(text_view: &TextView) {
let text_view = text_view.clone(); let text_view = text_view.clone();
let separator = separator.clone(); let separator = separator.clone();
move || { move || {
separator.set_width_request(text_view.width() - 18); let w = text_view.width();
ControlFlow::Break if w < OFFSET {
ControlFlow::Continue
} else {
separator.set_width_request(w - OFFSET);
ControlFlow::Break
}
} }
}); }); // @TODO something with the widgets init/activation priority..
let buffer = text_view.buffer(); let buffer = text_view.buffer();