diff --git a/src/containers/window.rs b/src/containers/window.rs index 9ee613c..3b3cbbe 100644 --- a/src/containers/window.rs +++ b/src/containers/window.rs @@ -59,8 +59,11 @@ macro_rules! define_window { y: usize, width: usize, height: usize, - ) -> Option> { - Window::new(self, x, y, width, height) + ) -> Option> { + if x + width >= self.width || y + height >= self.height { + return None; + } + Window::new(self.grid, self.x + x, self.y + y, width, height) } pub fn split_horizontal( @@ -165,8 +168,11 @@ impl<'t, TElement: Copy, TGrid: GridMut> y: usize, width: usize, height: usize, - ) -> Option> { - WindowMut::new(self, x, y, width, height) + ) -> Option> { + if x + width >= self.width || y + height >= self.height { + return None; + } + WindowMut::new(self.grid, self.x + x, self.y + y, width, height) } pub fn split_horizontal_mut(