on master help sign in
Fix lacking space panic (#6109)

* Fix lack of space for popup crash * Fix saturating -> wrapping * Fix wrapping -> saturating (I am an idiot) * Remove useless "mut" in helix-tui/src/buffer.rs Co-authored-by: Michael Davis <mcarsondavis@gmail.com> * Remove redundant bound-check * Return bound-check back * Add bound-check for set_style * Remove set_style bound-check * Revert bound-check --------- Co-authored-by: Michael Davis <mcarsondavis@gmail.com>

commitdef26966d22dfc4b9a74e51542db246ba52f3dc9 authornuid32 <91177333+nuid32@users.noreply.github.com> dateSun 5 Mar 2023, 16:43 (4 years ago) parentccdb144
2 files changed+3−6
helix-term/src/ui/markdown.rs+1−4 helix-view/src/graphics.rs+2−2
helix-term/src/ui/markdown.rs+1−4
@@ -342,13 +342,10 @@ impl Component for Markdown {
342342
343343 fn required_size(&mut self, viewport: (u16, u16)) -> Option<(u16, u16)> {
344344 let padding = 2;
345− if padding >= viewport.1 || padding >= viewport.0 {
346− return None;
347− }
348345 let contents = self.parse(None);
349346
350347 // TODO: account for tab width
351− let max_text_width = (viewport.0 - padding).min(120);
348+ let max_text_width = (viewport.0.saturating_sub(padding)).min(120);
352349 let (width, height) = crate::ui::text::required_size(&contents, max_text_width);
353350
354351 Some((width + padding, height + padding))
helix-view/src/graphics.rs+2−2
@@ -237,8 +237,8 @@ impl Rect {
237237 Rect {
238238 x: x1,
239239 y: y1,
240− width: x2 - x1,
241− height: y2 - y1,
240+ width: x2.saturating_sub(x1),
241+ height: y2.saturating_sub(y1),
242242 }
243243 }
244244