Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Checkpoint
Antonio Scandurra133c3a330c0c
diff --git a/crates/gpui3/src/geometry.rs b/crates/gpui3/src/geometry.rsindex c7af290e61a..d60866816d6 100644--- a/crates/gpui3/src/geometry.rs+++ b/crates/gpui3/src/geometry.rs@@ -1,7 +1,10 @@use core::fmt::Debug;use derive_more::{Add, AddAssign, Div, Mul, Sub, SubAssign};use refineable::Refineable;-use std::ops::{Add, AddAssign, Div, Mul, MulAssign, Sub, SubAssign};+use std::{+ cmp,+ ops::{Add, AddAssign, Div, Mul, MulAssign, Sub, SubAssign},+};#[derive(Refineable, Default, Add, AddAssign, Sub, SubAssign, Copy, Debug, PartialEq, Eq, Hash)]#[refineable(debug)]@@ -84,7 +87,7 @@ impl<T: Clone + Debug + Div<S, Output = T>, S: Clone> Div<S> for Point<T> {}}-impl<T: Clone + Debug + std::cmp::PartialOrd> Point<T> {+impl<T: Clone + Debug + cmp::PartialOrd> Point<T> {pub fn max(&self, other: &Self) -> Self {Point {x: if self.x >= other.x {@@ -99,6 +102,21 @@ impl<T: Clone + Debug + std::cmp::PartialOrd> Point<T> {},}}++ pub fn min(&self, other: &Self) -> Self {+ Point {+ x: if self.x <= other.x {+ self.x.clone()+ } else {+ other.x.clone()+ },+ y: if self.y <= other.y {+ self.y.clone()+ } else {+ other.y.clone()+ },+ }+ }}impl<T: Clone + Debug> Clone for Point<T> {@@ -239,6 +257,14 @@ impl<T: Clone + Debug + Sub<Output = T>> Bounds<T> {}}+impl<T: Clone + Debug + PartialOrd + Add<T, Output = T> + Sub<Output = T>> Bounds<T> {+ pub fn intersect(&self, other: &Self) -> Self {+ let upper_left = self.origin.max(&other.origin);+ let lower_right = self.lower_right().min(&other.lower_right());+ Self::from_corners(upper_left, lower_right)+ }+}+impl<T, Rhs> Mul<Rhs> for Bounds<T>whereT: Mul<Rhs, Output = Rhs> + Clone + Debug,@@ -537,7 +563,7 @@ impl Mul<Pixels> for Pixels {impl Eq for Pixels {}impl Ord for Pixels {- fn cmp(&self, other: &Self) -> std::cmp::Ordering {+ fn cmp(&self, other: &Self) -> cmp::Ordering {self.0.partial_cmp(&other.0).unwrap()}}diff --git a/crates/gpui3/src/window.rs b/crates/gpui3/src/window.rsindex 12bc21d9f0e..b92edb8ecef 100644--- a/crates/gpui3/src/window.rs+++ b/crates/gpui3/src/window.rs@@ -86,6 +86,15 @@ impl ContentMask {corner_radii: self.corner_radii.scale(factor),}}++ pub fn intersect(&self, other: &Self) -> Self {+ let bounds = self.bounds.intersect(&other.bounds);+ // todo!("intersect corner radii")+ ContentMask {+ bounds,+ corner_radii: self.corner_radii,+ }+ }}#[derive(Clone, Debug, PartialEq, Eq)]@@ -479,6 +488,7 @@ pub trait BorrowWindow: BorrowAppContext {fn window_mut(&mut self) -> &mut Window;fn with_content_mask<R>(&mut self, mask: ContentMask, f: impl FnOnce(&mut Self) -> R) -> R {+ let mask = mask.intersect(&self.content_mask());self.window_mut().content_mask_stack.push(mask);let result = f(self);self.window_mut().content_mask_stack.pop();