Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Ceil measured width for Text element

Antonio Scandurra6929a7182751
diff --git a/crates/gpui2/src/elements/text.rs b/crates/gpui2/src/elements/text.rs
index e258d3e7dc6..5c5709d32e5 100644
--- a/crates/gpui2/src/elements/text.rs
+++ b/crates/gpui2/src/elements/text.rs
@@ -101,7 +101,12 @@ impl<V: 'static> Element<V> for Text<V> {
.map(|line| line.wrap_count() + 1)
.sum::<usize>();
let size = Size {
- width: lines.iter().map(|line| line.layout.width).max().unwrap(),
+ width: lines
+ .iter()
+ .map(|line| line.layout.width)
+ .max()
+ .unwrap()
+ .ceil(),
height: line_height * line_count,
};
diff --git a/crates/gpui2/src/geometry.rs b/crates/gpui2/src/geometry.rs
index f290c6a81c1..e07300951ec 100644
--- a/crates/gpui2/src/geometry.rs
+++ b/crates/gpui2/src/geometry.rs
@@ -785,6 +785,10 @@ impl Pixels {
Self(self.0.round())
}
+ pub fn ceil(&self) -> Self {
+ Self(self.0.ceil())
+ }
+
pub fn scale(&self, factor: f32) -> ScaledPixels {
ScaledPixels(self.0 * factor)
}