Clip completion labels when they would otherwise overflow their container

Marshall Bowers and Julia created

Co-Authored-By: Julia <julia@zed.dev>

Change summary

crates/editor2/src/editor.rs                | 2 +-
crates/ui2/src/components/list/list_item.rs | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)

Detailed changes

crates/editor2/src/editor.rs 🔗

@@ -1266,7 +1266,7 @@ impl CompletionsMenu {
                                         )
                                         .map(|task| task.detach_and_log_err(cx));
                                 }))
-                                .child(completion_label)
+                                .child(h_stack().overflow_hidden().child(completion_label))
                                 .end_slot::<Div>(documentation_label),
                         )
                     })

crates/ui2/src/components/list/list_item.rs 🔗

@@ -224,6 +224,9 @@ impl RenderOnce for ListItem {
                     }))
                     .child(
                         h_stack()
+                            // HACK: We need to set *any* width value here in order for this container to size correctly.
+                            // Without this the `h_stack` will overflow the parent `inner_list_item`.
+                            .w_px()
                             .flex_1()
                             .gap_1()
                             .children(self.start_slot)