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.

gpui: Update Taffy 0.13 to 0.15 (#65950)

Anthony Eidb488c4e81451
diff --git a/Cargo.lock b/Cargo.lock
index 260d78e8bc8..e50c1d373a7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -17985,11 +17985,10 @@ dependencies = [
[[package]]
name = "taffy"
-version = "0.13.0"
+version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c034e05f6ee85a12daa63863c2245797715075c70649947aa0da54f3f2ab1d0f"
+checksum = "3c8480887e8803986d96a7173729565520d4bbb721ad6b7ad6941a22897207aa"
dependencies = [
- "arrayvec",
"serde",
"slotmap",
"smallvec",
diff --git a/Cargo.toml b/Cargo.toml
index 055fb7f0f8f..898da79fe57 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -909,7 +909,7 @@ swash = "0.2.6"
syn = { version = "2.0", default-features = false, features = ["proc-macro"] }
sys-locale = "0.3.1"
sysinfo = { version = "0.39", default-features = false, features = ["system"] }
-taffy = { version = "=0.13.0", default-features = false }
+taffy = { version = "=0.15.0", default-features = false }
tempfile = "3.20.0"
tendril = "0.5"
thiserror = "2.0.12"
diff --git a/crates/gpui/src/taffy.rs b/crates/gpui/src/taffy.rs
index b9e583a8df4..7c12b5cb8c1 100644
--- a/crates/gpui/src/taffy.rs
+++ b/crates/gpui/src/taffy.rs
@@ -236,32 +236,43 @@ impl TaffyLayoutEngine {
.compute_layout_with_measure(
id.into(),
available_space.into(),
- |known_dimensions, available_space, _id, node_context, _style| {
- let Some(node_context) = node_context else {
- return taffy::geometry::Size::default();
- };
-
- let known_dimensions = Size {
- width: known_dimensions.width.map(|e| Pixels(e / scale_factor)),
- height: known_dimensions.height.map(|e| Pixels(e / scale_factor)),
- };
-
- let available_space: Size<AvailableSpace> = available_space.into();
- let untransform = |ev: AvailableSpace| match ev {
- AvailableSpace::Definite(pixels) => {
- AvailableSpace::Definite(Pixels(pixels.0 / scale_factor))
- }
- AvailableSpace::MinContent => AvailableSpace::MinContent,
- AvailableSpace::MaxContent => AvailableSpace::MaxContent,
- };
- let available_space = size(
- untransform(available_space.width),
- untransform(available_space.height),
- );
-
- let measured_size: Size<Pixels> =
- (node_context.measure)(known_dimensions, available_space, window, cx);
- snap_measured_size_to_device_pixels(measured_size, scale_factor).into()
+ |input, _id, node_context, style| {
+ taffy::compute_leaf_layout(
+ input,
+ style,
+ |_, _| 0.0,
+ |known_dimensions, available_space| {
+ let Some(node_context) = node_context else {
+ return taffy::geometry::Size::default();
+ };
+
+ let known_dimensions = Size {
+ width: known_dimensions.width.map(|e| Pixels(e / scale_factor)),
+ height: known_dimensions.height.map(|e| Pixels(e / scale_factor)),
+ };
+
+ let available_space: Size<AvailableSpace> = available_space.into();
+ let untransform = |ev: AvailableSpace| match ev {
+ AvailableSpace::Definite(pixels) => {
+ AvailableSpace::Definite(Pixels(pixels.0 / scale_factor))
+ }
+ AvailableSpace::MinContent => AvailableSpace::MinContent,
+ AvailableSpace::MaxContent => AvailableSpace::MaxContent,
+ };
+ let available_space = size(
+ untransform(available_space.width),
+ untransform(available_space.height),
+ );
+
+ let measured_size: Size<Pixels> = (node_context.measure)(
+ known_dimensions,
+ available_space,
+ window,
+ cx,
+ );
+ snap_measured_size_to_device_pixels(measured_size, scale_factor).into()
+ },
+ )
},
)
.expect(EXPECT_MESSAGE);
@@ -493,10 +504,10 @@ impl ToTaffy<taffy::style::Style> for Style {
margin: self.margin.to_taffy(rem_size, scale_factor),
padding: self.padding.to_taffy(rem_size, scale_factor),
border: border_widths_to_taffy(&self.border_widths, rem_size, scale_factor),
- align_items: self.align_items.map(|x| x.into()),
+ align_items: self.align_items.map(Into::into).unwrap_or_default(),
align_self: self.align_self.map(|x| x.into()),
- align_content: self.align_content.map(|x| x.into()),
- justify_content: self.justify_content.map(|x| x.into()),
+ align_content: self.align_content.map(Into::into).unwrap_or_default(),
+ justify_content: self.justify_content.map(Into::into).unwrap_or_default(),
gap: self.gap.to_taffy(rem_size, scale_factor),
flex_direction: self.flex_direction.into(),
flex_wrap: self.flex_wrap.into(),
diff --git a/crates/markdown/src/markdown.rs b/crates/markdown/src/markdown.rs
index e4937fd1fd7..44e732c06c2 100644
--- a/crates/markdown/src/markdown.rs
+++ b/crates/markdown/src/markdown.rs
@@ -2309,8 +2309,7 @@ impl MarkdownElement {
range,
markdown_end,
);
- // Without `w_0`, text doesn't wrap to the width of the container.
- builder.push_div(div().flex_1().w_0(), range, markdown_end);
+ builder.push_div(div().flex_1().min_w_0(), range, markdown_end);
}
fn pop_markdown_list_item(&self, builder: &mut MarkdownElementBuilder) {