From 097c415036ed63c0736a6434ab9be25fbac042e1 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Thu, 28 Dec 2023 18:53:08 +0400 Subject: layout: Use saturating_add() in several places Apparently VSCode sends i32::MAX worth of max_size? --- src/layout/tile.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/layout/tile.rs b/src/layout/tile.rs index 3bc90687..bd684ea0 100644 --- a/src/layout/tile.rs +++ b/src/layout/tile.rs @@ -130,7 +130,8 @@ impl Tile { } if let Some(width) = self.effective_border_width() { - size += (width * 2, width * 2).into(); + size.w = size.w.saturating_add(width * 2); + size.h = size.h.saturating_add(width * 2); } size @@ -172,7 +173,7 @@ impl Tile { if self.border.is_off() { size } else { - size + self.border.width() * 2 + size.saturating_add(self.border.width() * 2) } } @@ -180,7 +181,7 @@ impl Tile { if self.border.is_off() { size } else { - size + self.border.width() * 2 + size.saturating_add(self.border.width() * 2) } } @@ -204,7 +205,9 @@ impl Tile { if let Some(width) = self.effective_border_width() { size.w = max(1, size.w); size.h = max(1, size.h); - size += (width * 2, width * 2).into(); + + size.w = size.w.saturating_add(width * 2); + size.h = size.h.saturating_add(width * 2); } size @@ -215,10 +218,10 @@ impl Tile { if let Some(width) = self.effective_border_width() { if size.w > 0 { - size.w += width * 2; + size.w = size.w.saturating_add(width * 2); } if size.h > 0 { - size.h += width * 2; + size.h = size.h.saturating_add(width * 2); } } -- cgit